In a Binary Search Tree (BST), for every node, all values in its left subtree are smaller, and all values in its right subtree are larger than the node's value.
Click to reveal answer
beginner
Why does the BST property matter for searching?
Because the BST property keeps smaller values to the left and larger to the right, it allows fast searching by deciding which subtree to explore next, reducing the search space quickly.
Click to reveal answer
beginner
How does the BST property help in inserting a new value?
When inserting, the BST property guides where to place the new value by comparing it with nodes, moving left if smaller or right if larger, ensuring the tree stays ordered.
Click to reveal answer
intermediate
What happens if the BST property is violated?
If the BST property is broken, searching and inserting become inefficient because the tree loses its order, possibly turning into a list and slowing operations to linear time.
Click to reveal answer
beginner
Explain the BST property using a real-life example.
Think of a phone book sorted by names: all names starting with A come before B, and so on. This order helps you quickly find a name by skipping large sections, just like BST property helps find values fast.
Click to reveal answer
What must be true for every node in a BST?
AAll values in left and right subtrees are equal
BLeft subtree values are larger, right subtree values are smaller
CLeft subtree values are smaller, right subtree values are larger
DNo specific order is required
✗ Incorrect
The BST property requires left subtree values to be smaller and right subtree values to be larger than the node.
Why does the BST property improve search speed?
AIt stores values randomly
BIt allows skipping half of the tree at each step
CIt duplicates values for faster access
DIt uses a queue to find values
✗ Incorrect
Because values are ordered, you can decide to go left or right, skipping half the nodes each time.
If a new value is smaller than a node's value, where should it go in a BST?
ALeft subtree
BRight subtree
CAt the node itself
DAnywhere in the tree
✗ Incorrect
Smaller values go to the left subtree to maintain the BST property.
What is a consequence of violating the BST property?
ASearch and insert become slower
BTree becomes balanced automatically
CValues get sorted faster
DNo effect on operations
✗ Incorrect
Violating the property can make the tree unorganized, slowing down operations.
Which real-life example best illustrates the BST property?
AA shuffled deck of cards
BA pile of unsorted papers
CA random list of names
DA sorted phone book
✗ Incorrect
A sorted phone book helps find names quickly, similar to how BST property organizes values.
Describe the BST property and explain why it is important for efficient searching.
Think about how the tree guides you to find values quickly.
You got /5 concepts.
Explain what could happen if the BST property is not maintained in a tree.
Consider how the tree's structure affects speed.
You got /4 concepts.
Practice
(1/5)
1. What is the main property that defines a Binary Search Tree (BST)?
easy
A. Left child nodes have smaller values, right child nodes have larger values
B. All nodes have exactly two children
C. Nodes are arranged in a circular linked list
D. Each node stores the sum of its children
Solution
Step 1: Understand BST node arrangement
In a BST, every node's left child has a smaller value and the right child has a larger value.
Step 2: Compare with other options
Other options describe different data structures or incorrect properties.
Final Answer:
Left child nodes have smaller values, right child nodes have larger values -> Option A
Quick Check:
BST property = Left smaller, right larger [OK]
Hint: Remember BST orders left < node < right [OK]
Common Mistakes:
Thinking all nodes must have two children
Confusing BST with binary tree
Assuming nodes store sums
2. Which TypeScript interface correctly represents a BST node?
easy
A. interface Node { value: number; parent: Node; }