Overview - Floor and Ceil in BST
What is it?
Floor and Ceil in a Binary Search Tree (BST) are two special values related to a given number. The floor is the greatest value in the BST that is less than or equal to the given number. The ceil is the smallest value in the BST that is greater than or equal to the given number. These help us quickly find closest matches in sorted data stored in a tree.
Why it matters
Without floor and ceil operations, finding closest smaller or larger values in sorted data would be slow and inefficient. They allow fast queries in many applications like searching ranges, nearest neighbors, or decision making. This makes BSTs more powerful and practical for real-world problems involving ordered data.
Where it fits
Before learning floor and ceil in BST, you should understand what a Binary Search Tree is and how searching works in it. After mastering floor and ceil, you can explore related topics like range queries, predecessor and successor in BST, and balanced BSTs like AVL or Red-Black trees.
