Question

What are the differences and similarities between Binary Search Trees and heap. c++ programming

What are the differences and similarities between Binary Search Trees and heap.

c++ programming

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

both are binary trees
in binary search tree at each node n, all leftnodes of n are less than n, and all right nodes of n are greater than n
in heap, if it is min heap, then at each node n, all its childs are all greater than n, if it is max heap then all childs of n are less than n
and heap is left justified complete tree
search operation complexity:
   in heap it is O(n) in best and worst case
   in binary search tree it is O(n) in worst case, O(logn) in best and average case
insertion and deletion complexity:
   in heap it is O(logn)
   in binary search tree it is O(logn) in best case and O(n) in worst case
getMin or getmax operation complexity:
   in heap it is O(1)
   in binary search tree it is O(n)

Add a comment
Know the answer?
Add Answer to:
What are the differences and similarities between Binary Search Trees and heap. c++ programming
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