Hash table - implementing with Binary Search Tree

前端 未结 3 1804
别跟我提以往
别跟我提以往 2021-02-10 07:19

From Cracking the Coding Interview, page 71:

Alternatively, we can implement hash table with a BST. We can then guarantee an O(log n) lookup ti

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-10 07:58

    You're conflating a few terms here.

    • The idea would be to implement the hash table with both the array and a BST in a two-tiered fashion. One would still add values into the hash if there were no collision, but if there was, then one could solve the performance of retrieving a collided element with the BST.

    • A trie is something entirely different; depending on what you were attempting to store, you might not be able to apply it to a hashing function.

提交回复
热议问题