Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • hash tables don't use BSTs. BSTs don't require hash values. Maps and Sets can be implemented as BSTs though. Commented May 5, 2010 at 8:08
  • 3
    @Nick: Eh? No...BSTs don't require hash values... that's the point. We're assuming that at this point we already have a collision (same hash... or at least same bucket), so we need to look at something else to find the right element, i.e., the actual value. Commented May 5, 2010 at 8:12
  • 1
    oh, I see your point. But I'm not sure that mixing BSTs and hashes worth the trouble. Why not just use BSTs? Commented May 5, 2010 at 8:20
  • 2
    I'm just saying that you could to get rid of that O(n) for collisions. If you are expecting lots of collisions, then you're right, probably better off going with a BST in the first place. Commented May 5, 2010 at 8:25
  • 1
    @spaaarky21 Right, but N in that case is the length of the string. We only need to hash one string to determine which 'bucket' it needs to go in -- it does not grow with the length of the hashmap. Commented Mar 31, 2017 at 19:38