Question

Binary Search Trees can be used to implement Maps. Discuss the pros and cons of this...

Binary Search Trees can be used to implement Maps. Discuss the pros and cons of this in terms of performance. Are there any unique benefits of using a Binary Search Tree to implement a map?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Binary Search Trees use self balancing. Hash tables are used for operations internal maps.

Pros

1) With BST the insert, delete operations are done in O(log n) times whereas in hashing it can be done using O(1) time. (best case) worst case being O(n) with collision of all data. BST's complexity remains same even in worst case so that's an advantage.

2) BSTs are very easy to implement in any language and hashing is a complicated process.

3) BST is cost effective and hashing is costly. Even resizing creates lot of trouble with hashing.

4) BST stores in sorted manner. Hash table doesn't this is an added advantage with BST

Cons

1) Since complexity is O(log n) throughout, hash function optimizations give O(1) complexity most of the times. So BST is slower in comparison

Unique benefit is the sorted order of stored items which is random otherwise

Add a comment
Know the answer?
Add Answer to:
Binary Search Trees can be used to implement Maps. Discuss the pros and cons of this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT