Recall & Review
beginner
What is a Binary Search Tree (BST)?
A BST is a tree where each node has at most two children. The left child's value is less than the parent node's value, and the right child's value is greater. This helps in fast searching and insertion.
Click to reveal answer
beginner
What is the main rule to follow when inserting a new value in a BST?
Compare the new value with the current node. If smaller, go to the left child; if larger, go to the right child. Repeat until you find an empty spot to insert the new node.
Click to reveal answer
intermediate
Why do we insert nodes recursively in a BST?
Recursion helps to move down the tree easily by calling the same insert function on left or right child until the correct empty spot is found.
Click to reveal answer
intermediate
What happens if you try to insert a value that already exists in the BST?
Usually, BSTs do not allow duplicate values. The insert operation will find the existing value and not insert a new node.
Click to reveal answer
beginner
Show the state of BST after inserting 5, 3, 7 in an empty BST.
5 is the root node, with 3 as its left child and 7 as its right child. Both 3 and 7 have null children.
Click to reveal answer
When inserting a value into a BST, where do you go if the value is less than the current node?
✗ Incorrect
In a BST, smaller values go to the left child.
What is the time complexity of inserting a node in a balanced BST?
✗ Incorrect
In a balanced BST, insertion takes O(log n) time because we halve the search space at each step.
If the BST is empty, what happens when you insert a new value?
✗ Incorrect
If the BST is empty, the first inserted value becomes the root.
Which traversal order is best to print BST values in ascending order?
✗ Incorrect
Inorder traversal visits nodes in ascending order in a BST.
What is the first step in the BST insert operation?
✗ Incorrect
Insertion starts by comparing the new value with the root node.
Explain how to insert a new value into a Binary Search Tree step-by-step.
Think about how you decide where to place the new value.
You got /5 concepts.
Describe what the BST looks like after inserting the values 10, 5, 15, 3, 7 in order.
Draw the tree step by step as you insert each value.
You got /4 concepts.