Question

Why would you use an AVL tree over an array structure for determining if a value...

Why would you use an AVL tree over an array structure for determining if a value was seen before? Is there ever a case where the array would be a better choice?

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

Why would you use an AVL tree over an array structure for determining if a value was seen before?
->AVL Tree searches a given element in O(logn) time because it is a balanced binary search tree . So It takes logn time to determine if a value was seen before where as array will take O(n) time to determine that . Hence AVL is better than array

Is there ever a case where the array would be a better choice?
->Yes, when the data is sorted , Determining duplicate in array will take logn time , where as AVL will also take logn time but we will prefer array because of its simpler structure and memory requirements. For AVL tree we need to store two extra references (left and right) along with data. Hence when the data is sorted we would prefer array

Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
Why would you use an AVL tree over an array structure for determining if a value...
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