Floor and Ceil in BST
📖 Scenario: You are working with a phone book application that stores contacts in a Binary Search Tree (BST) by their phone numbers. You want to find the closest phone number less than or equal to a given number (floor) and the closest phone number greater than or equal to that number (ceil).
🎯 Goal: Build a TypeScript program that creates a BST with given phone numbers, then finds the floor and ceil values for a target phone number.
📋 What You'll Learn
Create a BST node class called
Node with data, left, and right propertiesCreate a BST by inserting given phone numbers in order
Create a variable called
target with the exact value 65Write functions
floorInBST and ceilInBST that find floor and ceil values for targetPrint the floor and ceil values exactly as shown
💡 Why This Matters
🌍 Real World
Finding floor and ceil values in a BST is useful in applications like phone book lookups, price filtering, and range queries where you want the closest available value to a target.
💼 Career
Understanding BST operations and floor/ceil logic is important for software engineers working on search engines, databases, and any system requiring efficient data retrieval.
Progress0 / 4 steps