0
0
DSA Typescriptprogramming~5 mins

Floor and Ceil in BST in DSA Typescript - 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 than scanning the whole tree.
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 current node's value, which subtree should you explore to find the floor?
You should explore the left subtree because all values in the right subtree are greater than the current node's value, which is already bigger than the target.
Click to reveal answer
What does the floor of a value in a BST represent?
AThe smallest value greater than or equal to the target
BThe exact value only if it exists
CThe root value of the BST
DThe greatest value less than or equal to the target
If the target value is greater than the current node's value, where should you look to find the ceil?
ARight subtree
BLeft subtree
CCurrent node only
DBoth subtrees
When the current node's value equals the target, what is the floor and ceil?
AFloor is smaller, ceil is larger
BBoth floor and ceil are the current node's value
CFloor is null, ceil is current node's value
DFloor is current node's value, ceil is null
Which property of BST helps in finding floor and ceil efficiently?
ANodes are stored in a linked list
BNodes are stored in a queue
CLeft child is always smaller, right child is always larger
DAll nodes have two children
If the target value is smaller than the current node's value, which subtree is explored to find the ceil?
ALeft subtree
BRight subtree
CCurrent node only
DNo subtree
Explain how to find the floor of a given value in a BST step-by-step.
Think about how BST ordering guides your search direction.
You got /6 concepts.
    Describe the difference between floor and ceil in a BST with examples.
    Use simple numbers to illustrate the concept.
    You got /5 concepts.