What is the maximum height of an AVL tree with p nodes?
Origin of the question is AVL Tree topic in chapter Binary Trees of Data Structures & Algorithms I
This question was posed to me in an interview.
Right option is (b) log(p)
Easy explanation – Consider height of tree to be ‘he’, then number of nodes which totals to p can be written in terms of height as N(he)=N(he-1)+1+N(he-2). since N(he) which is p can be written in terms of height as the beside recurrence relation which on solving gives N(he)= O(logp) as worst case height.