When would you use BST over a hash, assuming perfect hashing
A BST may be used when we search a range of values. It is easy to find node contained in range of value
Using a hash you should search each value through hashing function and hash table, that is not efficient.
BST allows insert, delete, lookup, find_min and find_max at O(logn) time, while hash only supports insert, delete and lookup and constant time.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment