Member-only story
Data Structures and Algorithms (DSA) using C# .NET Core — Binary Search Trees- III
Now that we have understood types of binary tree, there is one very important Binary tree type and that is Binary Search Tree also know as BST.
Introduction:
Binary Search Tree (BST) is a data structure that is a collection of nodes. Its called a binary tree because each node in the tree has a maximum of two children's and its called a Search tree because it can be used to search an item in O(log(n)) times.
What separates a Binary Search Tree (BST) from a Binary Tree ?
The value of the node in the right sub-tree should be greater that the root node and the value in the left sub-tree should be smaller than the root node. ( In other words — for each node — its value must be less that the value in the right sub-tree and greater than the value in the left sub-tree.)