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 70, 42, 33, 15 and 14, in that order. How many comparisons do the five puts make in all?
the answer, and why
the answer is D
70 is the top, 0. 42 meets 70, 1. 33 meets 70 and 42, 2, then turn right at 70: 42 moves up. 15 meets 42 and 33, 2. 14 meets 42, 33 and 15, 3, then turn right at 33. That is 8.
if you chose another
AThat is the plain tree's count. With no turns, each number meets every number before it.
BThat is middle first's, the cheapest order of five; here 33 meets 70 and 42 before the tree turns.
CThat counts one comparison a put, but later puts go deeper.