Minimal AVL Tree Recurrence

Algebra Level 3

Let T ( d ) T(d) denote the smallest size of an AVL tree of depth d d . Clearly T ( 0 ) = 1 T(0) = 1 and T ( 1 ) = 2 T(1) = 2

Which of the following recurrences does T T satisfy?

  1. T ( d ) = T ( d 1 ) + T ( d 2 ) T(d) = T(d-1) + T(d-2)
  2. T ( d ) = T ( d 1 ) + T ( d 2 ) + 1 T(d) = T(d-1) + T(d-2) +1
  3. T ( d ) = 1 + 2 T ( d 1 ) T(d) = 1 + 2T(d-1)
  4. T ( d ) = 2 T ( d 2 ) T(d) = 2T(d-2)
  5. T ( d ) = T ( d / 2 ) 2 T(d) = T(d/2)^2
  6. None of the above


The answer is 2.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Varsha Dani
Jan 30, 2019

The answer is T ( d ) = T ( d 1 ) + T ( d 2 ) + 1 \boxed{ T(d) = T(d-1) + T(d-2) +1} .

In an AVL tree, each vertex has the property that the depths of its left and right subtrees differ by at most 1. In particular this is true of the root. Let us consider the subtrees of the root. One of them must have depth d 1 d-1 , since the depth of the whole tree is d d . The AVL property allows the other tree to have depth d 1 d-1 or d 2 d-2 (it can't be d d since that is the depth of the entire tree). The minimality of the size of the tree implies that in fact the depth of the second subtree must be d 2 d-2 . Furthermore, Since the entire tree is of minimal size, the subtrees themselves must be of minimal size for their depths, so that their sizes are T ( d 1 ) T(d-1) and T ( d 2 ) T(d-2) respectively. Adding 1 for the root gives the relevant recurrence.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...