Question

In regards to binary search tree, can you answer why a BST with N nodes has...

In regards to binary search tree, can you answer why a BST with N nodes has at least log2N levels and at most N levels. so the runtime complexity is best case 0(logN) and worst case 0(N). Can you explain this with the following numbers in this order? 7,1,64,28,77

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

There are two cases for a BST, balanced BST and unbalanced BST. Unbalanced BST is a skewed BST. For a balanced BST, for every node, the difference between the left height and right height is atmost 1.

For a balanced BST, there will be logN levels and for an unbalanced tree, there will be N levels. Time complexity is O(height) where height is the height of the tree. For a balanced BST, height is logN and for an unbalanced BST, height is N, hence the time complexity.

SOLUTION Insert 7 Insert Insest 64 7 ° 0 (64) insert 28 7 0 (641 0 (28) Insest 77 e Balanced binary search tree event logs I

Please give an upvote if you liked my solution. Thank you :)

Add a comment
Know the answer?
Add Answer to:
In regards to binary search tree, can you answer why a BST with N nodes has...
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
ADVERTISEMENT