educative.io

Educative

HashTable Implementation

the resource says the time complexity for the search is O(1) but I’m wondering why that is so, because of the while loop been used in it specifically here
if (head != null) {
while (head != null) {
if (head.key == key) {
return head.value;
}
head = head.next
}
}

shouldn’t it be O(m) where m is the length of the records in a bucket slot,

Also the example been used, inserts strings into the hash table which stores all the records at the position of NaN. is that intentional


Course: https://www.educative.io/collection/5642554087309312/5663204961157120
Lesson: https://www.educative.io/collection/page/5642554087309312/5663204961157120/5656782173110272