Binary Search & Balanced Trees


Answer & solution
Answer: Root stop; left child if; right child while (no official key was published)
The alphabetic order is if<stop<while. Placing the middle identifier at the root preserves search-tree ordering with the other two as its children. Successful search takes one comparison at the root and two at either child, for mean (1+2+2)/3=5/3. Any endpoint root forces the remaining two into one subtree, creating depths corresponding to comparison counts 1, 2, 3 and mean 2. Thus the balanced tree is optimal. The calculation uses equal successful-search probabilities; unspecified unequal unsuccessful-search gap weights would define a different optimization problem.