Recall & Review
beginner
What is the minimum element in a Binary Search Tree (BST)?
The minimum element in a BST is the leftmost node because all smaller values are stored to the left.
Click to reveal answer
beginner
How do you find the minimum element in a BST?
Start at the root and keep moving to the left child until you reach a node with no left child. That node is the minimum.
Click to reveal answer
intermediate
Why does the minimum element in a BST always lie in the left subtree?
Because BST property states left child nodes have smaller values than their parents, so the smallest value is found by going left repeatedly.
Click to reveal answer
intermediate
What is the time complexity to find the minimum element in a BST?
The time complexity is O(h), where h is the height of the BST. In the worst case (skewed tree), it can be O(n).
Click to reveal answer
beginner
Show the TypeScript code snippet to find the minimum element in a BST node.
function findMin(root: TreeNode | null): TreeNode | null {
if (!root) return null;
while (root.left !== null) {
root = root.left;
}
return root;
}Click to reveal answer
Where is the minimum element located in a BST?
✗ Incorrect
The minimum element is always the leftmost node in a BST.
What do you do if the BST root has no left child when finding the minimum?
✗ Incorrect
If the root has no left child, it is the minimum element.
What is the time complexity to find the minimum element in a balanced BST with n nodes?
✗ Incorrect
In a balanced BST, height h is about log n, so finding minimum is O(log n).
Which of these is NOT true about the minimum element in a BST?
✗ Incorrect
The minimum element is not always the root; it depends on the tree structure.
What happens if you try to find the minimum in an empty BST?
✗ Incorrect
If the BST is empty (root is null), the function returns null.
Explain step-by-step how to find the minimum element in a BST.
Think about the BST property and left children.
You got /4 concepts.
Write a simple TypeScript function to find the minimum element in a BST and explain its time complexity.
Use a loop to go left until no more left child.
You got /4 concepts.