I have a question: given that an AVL tree holds numbers 1, 2, 3, ..., 1000, what are the smallest and largest possible values of the root?
I have a feeling it is 500 and 501, but I don't know how to prove this.
To start with, I created a formula using a recurrence $N(h)=N(h-1)+N(h-2)+1$ for the minimum number of nodes given an AVL tree of height $h$, $N(h)$. This comes out as $$N(h)=\frac{5+10\sqrt{5}}{5}\left(\frac{1+\sqrt{5}}{2}\right)^h+\frac{5-10\sqrt{5}}{5}\left(\frac{1-\sqrt{5}}{2}\right)^h$$and the maximum value for an AVL tree of height $h$ is clearly $M(h)=2^{h+1}-1$.
Since we're working with an AVL tree the left and right subtrees of the root must have heights differing by at most 1.
To find the smallest root value, we need as few numbers in the left subtree as possible. This means we also want to minimise the height, but we also require that the height $h_L$ is no smaller than $h_R-1$. Setting $h_R=h_L+1$ I tried using $N(h_L)+M(h_L+1)=1000$, but I'm really not sure how this would help.
I would ideally prefer to find a much less maths-based solution for this problem. Could anyone help?