Question Bank

Binary Search Tree Basics

Difficulty: Easy

Quick drills on the BST ordering invariant, in-order traversal yielding sorted output, and the most common search and insert operations.

Question Bank
/

Binary Search Tree Basics

Binary Search Tree Basics

Quick drills on the BST ordering invariant, in-order traversal yielding sorted output, and the most common search and insert operations.

Question Bank
Easy
JavaScript
4 questions
bst
binary-tree
data-structures
fundamentals

690 views

13

State the BST ordering invariant in one sentence, then check whether the tree built below satisfies it. If not, name the offending node.

Examples

Example 1:

Input: tree 10 -> (5 -> (2, 7), 15 -> (12, 20))
Output: valid BST; in-order traversal = [2, 5, 7, 10, 12, 15, 20]
Explanation: For every node, all values in the left subtree are strictly less and all values in the right subtree are strictly greater. The sorted in-order traversal confirms the invariant.