Introduction to Binary Search Tree Last Updated : 08 Dec, 2025 Comments Improve Suggest changes 49 Likes Like Report A Binary Search Tree (BST) is a special type of binary tree that maintains its elements in a sorted order. It is a non-linear, hierarchical data structure, where each node can have at most two children, and elements are organized in a parent-child relationship. For every node in the BST:All nodes in its left subtree have values less than the node’s value.All nodes in its right subtree have values greater than the node’s value.This property ensures that each comparison allows the operation to skip about half of the remaining tree, making BST operations much faster than linear structures like arrays or linked lists. Key Properties Unique ordering of elements means duplicates are usually not allowed. Inorder traversal of a BST gives sorted order of elements. Average height: O(log n) (for balanced BST). Worst case height: O(n) (when tree becomes skewed).Operations in BSTSearch : Finds whether a given key exists in the BST. Time Complexity on average is O(log n) and worst case is O(n)Insertion : Insert a new node while maintaining BST property. Compare key with current node and move left/right recursively or iteratively. Time Complexity on average is O(log n) and worst case is O(n)Deletion : Remove a node while keeping BST valid. Node has no children means remove directly. Node has one child means replace node with its child. Node has two children means replace node with inorder successor/predecessor and delete that successor/predecessor. Time Complexity: average O(logn) and O(n) worst caseTraversals : The four common tree traversals are Inorder (Left, Root, Right) which gives nodes in sorted order for a BST, Preorder (Root, Left, Right), Postorder (Left, Right, Root), and Level-order, which traverses the tree level by level using a queue.Application of Binary Search TreeSearching and indexing (e.g., maps, sets).Dynamic sorting and range queries.Implementing symbol tables in compilers.Used in advanced structures (AVL Tree, Red-Black Tree, Splay Tree).Next Articles:Applications, Advantages and Disadvantages of Binary Search TreeInsertion in Binary Search Tree (BST)Searching in Binary Search Tree (BST)Deletion in Binary Search Tree (BST) Create Quiz Binary Search Tree(Background) Visit Course Binary Search Tree(Background) Binary Search Tree(Introduction) Comment K kartik Follow 49 Improve K kartik Follow 49 Improve Article Tags : Binary Search Tree Advanced Data Structure DSA Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 3 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 15 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 1 min read Problem of The Day - Develop the Habit of Coding 5 min read Like