0
0
DSA Typescriptprogramming~5 mins

BST Find Minimum Element in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ARoot node
BRightmost node
CLeftmost node
DAny leaf node
What do you do if the BST root has no left child when finding the minimum?
AReturn null
BSearch both children
CGo to the right child
DReturn the root node
What is the time complexity to find the minimum element in a balanced BST with n nodes?
AO(log n)
BO(n)
CO(1)
DO(n log n)
Which of these is NOT true about the minimum element in a BST?
AIt is always the root
BIt is the leftmost node
CIt has no left child
DIt is smaller than all other nodes
What happens if you try to find the minimum in an empty BST?
AReturn root
BReturn null
CThrow an error
DReturn a default value
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.