Binary Trees as Dictionaries in Data Structure

When we try to implement abstract data type Dictionary, then the node associates with values. A dictionary is basically a set of keys, which must be elements drawn from a total ordering. There may be additional information, which are associated with each key, but it does not lead to any conceptual comprehension.

If the dictionary is implemented using trees, then each node will hold unique keys. Here for each node u in the tree, every key is u.l is strictly smaller than u.k. And every key in u.r, is strictly larger than u.k. A tree is organized according to this invariant as referred to as a binary search tree.

One of the major advantage of this invariant is that, sorted list of keys can be found in linear time using in-order traversal. This can be defined recursively as follows − One empty tree, do nothing, otherwise recurs on the left subtree first, take the root, and report it. Then recur to the right subtree.

We can do multiple operations for binary search tree. The searching cane be done based on the height of the tree. Searching is more important operation of all other operations.

Updated on: 11-Aug-2020


Kickstart Your Career

Get certified by completing the course

Get Started