I am currently bushing up on my data structures and basic algorithms, part of th
ID: 651125 • Letter: I
Question
I am currently bushing up on my data structures and basic algorithms, part of that is the Binary Tree. I do understand the algorithms, and how to implement a binary search tree and such. I do so how smart it is that we can do lookups in O(log n) time.
I am however having a hard time finding an example of when I would use a binary tree, where a hash tables would not do the same/better job. I have been doing some searching around and found that it is used for 3D graphis, something about what items are to be displayed, i do however have a hard time relating to this.
Can any one give me an example where it would be better to user a binary tree over a hash table?
Explanation / Answer
Hash tables can only tell you if an element is present or not.
Here are somethings you can do with a binary tree that you can't do wiht a hash table.
sorted traversal of the tree
find the next closest element
find all elements less than or greater than a certain value
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.