Binary search tree

A binary search tree (BST) is a special type of binary tree where the nodes are stored in a sorted manner. It is sorted in such a way that at any given point, a node value must be greater than or equal to the left child node value and smaller than the right child node value. Each node has to satisfy this property to consider it as a binary search tree. Since the nodes are sorted in a particular order, the binary search algorithm can be applied to search items in a BST in logarithmic time. It is always better than linear searching, which takes O(n) time, and we will explore it in the next chapter. Here is an example of a binary search tree:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset