0
0
DSA C++programming~5 mins

Floor and Ceil in BST in DSA C++ - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the floor of a value in a Binary Search Tree (BST)?
The floor of a value in a BST is the greatest value in the BST that is less than or equal to the given value.
Click to reveal answer
beginner
What is the ceil of a value in a Binary Search Tree (BST)?
The ceil of a value in a BST is the smallest value in the BST that is greater than or equal to the given value.
Click to reveal answer
intermediate
How does the BST property help in finding floor and ceil efficiently?
Because BST nodes are ordered, we can decide to go left or right at each node to find floor or ceil without checking all nodes, making the search faster.
Click to reveal answer
beginner
In a BST, if the current node's value is equal to the target value, what are the floor and ceil?
Both floor and ceil are the current node's value because it exactly matches the target.
Click to reveal answer
intermediate
If the target value is smaller than the smallest value in the BST, what is the floor and ceil?
Floor does not exist (no value less than or equal), ceil is the smallest value in the BST.
Click to reveal answer
What does the floor of a value in a BST represent?
AThe average of all values in the BST
BThe smallest value greater than or equal to the target
CThe root value of the BST
DThe greatest value less than or equal to the target
If the target value equals a node's value in BST, what is the ceil?
AThe node's value itself
BA value smaller than the target
CThe largest value in the BST
DNo ceil exists
Which direction do you move in BST if current node's value is greater than target when finding floor?
ALeft subtree
BStay at current node
CRight subtree
DNo movement needed
What is the time complexity to find floor or ceil in a balanced BST?
AO(n log n)
BO(n)
CO(log n)
DO(1)
If target is smaller than all BST values, what is the floor?
ASmallest BST value
BNo floor exists
CTarget itself
DLargest BST value
Explain how to find the floor of a given value in a BST step-by-step.
Think about how BST ordering helps decide direction.
You got /6 concepts.
    Describe the difference between floor and ceil in a BST with examples.
    Use a simple BST and a target value between nodes.
    You got /4 concepts.