Floor and Ceil in BST
📖 Scenario: You are working with a Binary Search Tree (BST) that stores integer values. You want to find the floor and ceil values for a given number in the BST. The floor is the greatest value in the BST less than or equal to the given number. The ceil is the smallest value in the BST greater than or equal to the given number.This is useful in many real-world cases like finding closest available prices, dates, or scores.
🎯 Goal: Build a Go program that creates a BST, sets a target number, finds the floor and ceil values for that number in the BST, and prints the results.
📋 What You'll Learn
Create a BST with exact nodes: 20, 10, 30, 5, 15, 25, 35
Set a target number variable called
target with value 16Implement functions
floorBST and ceilBST to find floor and ceil valuesPrint the floor and ceil values for the target number
💡 Why This Matters
🌍 Real World
Finding floor and ceil values in a BST is useful in applications like price matching, scheduling, and range queries where you want closest available values.
💼 Career
Understanding BST operations and floor/ceil logic is important for software engineers working on search engines, databases, and real-time systems.
Progress0 / 4 steps