AlgoScope

BST Insert

Search for the value and hang a new leaf wherever the search runs out of tree.

Tree algorithms, algorithm, beginner
Comparing 65 with node 50. 65 is larger, so move to the right child, node 70.20304050607080current50 < 65
Comparing 65 with node 50. 65 is larger, so move to the right child, node 70.20304050607080current50 < 65

Binary Search Tree: Insert 65

Decision, step 2 of 6

65 is larger than 50: go right.

How binary search tree works

Cost

Best
O(1)
Average
O(log n)
Worst
O(n)
Space
O(1)

Leads to

Topics that need this one first.

Taught by the same lesson

Binary Search Tree covers these too, in the same run.