Also called Self-balancing binary search tree and Adelson-Velsky and Landis tree.
fresh numbers
The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from avl tree's own run on the numbers shown.
choose one
1question 1
An empty AVL tree puts in 86, 73, 41, 30 and 1, in that order. How many comparisons do the five puts make in all?
the answer, and why
the answer is A
86 is the top, 0. 73 meets 86, 1. 41 meets 86 and 73, 2, then turn right at 86: 73 moves up. 30 meets 73 and 41, 2. 1 meets 73, 41 and 30, 3, then turn right at 41. That is 8.
if you chose another
BThat is the plain tree's count. With no turns, each number meets every number before it.
CThat is middle first's, the cheapest order of five; here 41 meets 86 and 73 before the tree turns.
DThat counts one comparison a put, but later puts go deeper.