Properties of Binary Search Tree
- The left subtree of a node contains only nodes with keys lesser than the node’s key.
- The right subtree of a node contains only nodes with keys greater than the node’s key.
- This means everything to the left of the root is less than the value of the root and everything to the right of the root is greater than the value of the root. Due to this performing, a binary search is very easy.
- The left and right subtree each must also be a binary search tree.
- There must be no duplicate nodes(BST may have duplicate values with different handling approaches)
Handling duplicate values in the Binary Search Tree:
- We must follow a consistent process throughout i.e. either store duplicate value at the left or store the duplicate value at the right of the root, but be consistent with your approach.
Introduction to Binary Search Tree – Data Structure and Algorithm Tutorials
Binary Search Tree is a data structure used in computer science for organizing and storing data in a sorted manner. Binary search tree follows all properties of binary tree and its left child contains values less than the parent node and the right child contains values greater than the parent node. This hierarchical structure allows for efficient Searching, Insertion, and Deletion operations on the data stored in the tree.
Table of Content
- What is Binary Search Tree?
- Properties of Binary Search Tree
- Handling duplicate values in the Binary Search Tree
- Operations performed on a BST
- 1. Searching a node in BST
- 2. Insert a node into a BST
- 3. Delete a Node of BST
- 4. Traversal (Inorder traversal of BST)
- Applications of BST
- Advantages
- Disadvantages
- FAQ’s (Frequently asked questions) on Binary Search Tree: