So I am building a hashtable from scratch using linear probing in Java with the following methods: put(int key, String value), get(int key), remove(int key) and size(). So I successfully implemented these methods, but I have a theoretical question. Let say for example, I do the following:
var map = new HashMap(5);
map.put(1, "a");
map.put(3, "b");
map.put(4, "c");
map.put(8, "d");
map.put(13, "e");
map.remove(8);
System.out.println(map);
System.out.println(map.get(13));
My put method is working correctly and placing the key-value pairs according to Linear probing algo. Now my output is:
[null, 1=a, 13=e, 3=b, 4=c] null
So my question is, should my 'get' method theoretically fail (because of linear probing) to get the key-value pair 13=e because there of the remove method putting a null at index 0. Also if i don't use the remove, I'm successfully getting the 13=e pair.