Isn't the time complexity actually linear for lookups? Your implementation has constant bucket count, and the hash function is a recipe for collisions. Also, correct me, but I don't see any code for deletions.
You're right but this is how I intended the code: "pseudo code to explain how a hash table might work" not "this is the most efficient way to implement a hash table on top of an array" which as you notice has linear lookups.
Sure it is merely an example. The problem is that we seem to be talking about time complexity of an unspecified implementation instead of the one in the article, without noting it anywhere.
Isn't the time complexity actually linear for lookups? Your implementation has constant bucket count, and the hash function is a recipe for collisions. Also, correct me, but I don't see any code for deletions.
You're right but this is how I intended the code: "pseudo code to explain how a hash table might work" not "this is the most efficient way to implement a hash table on top of an array" which as you notice has linear lookups.
Sure it is merely an example. The problem is that we seem to be talking about time complexity of an unspecified implementation instead of the one in the article, without noting it anywhere.
True βΊοΈ