Binary Search Tree Program

Binary Search Tree Program

A binary search tree is a tree in which the data in left subtree is less than the root and the data in right subtree is greater than the root. In this article , we will cover all the basics of binary search tree.

Binary Search Tree : Basics
Rules Bst - Binary Search Tree - Program

Reprsentation Of BST:

  1. The representation of a BST is similar to that of a binary tree. The order of a BST is ‘2’. Each node can have at most two children.
  2. Only difference between the two is that there is a certain criteria of arrangement or insertion of the elements based on their comparisons with the root node and the sub tree segment they are added to.
Representation of BST

Operations In A BST:

  1. Traversal
  2. Searching
  3. Insertion
  4. Deletion

Features Of A BST:

  1. Fast look-up.
  2. Efficient addition and removal of items.
  3. Used to implement dynamic set of items

Advantages Of BST:

  1. Inorder Traversal gives sorted order of elements.
  2. Easy to implement order statistics.
  3. Helpful in range queries.

Disadvantages Of BST:

  1. The cost of operations may be high.
  2. Shape of tree depends on insetions and may be degenerated.
Inorder traversal of BST