The 6th-largest element can be much farther out. The extreme case is where the first six elements are the root and a series of right-children. Each child is at node 2n+1
, where n
is the parent's node. The sequence of indices for the right-most sequence is 1, 3, 7, 15, 31, 63 (a.k.a. 2^6-1). Other, smaller values fill in the left side of each branch.
The earliest position is if that same value happened to be the left-child of the root, while all of the others went to the right branch: it appears in location 2. Again, smaller values appear as needed.
So, the range of possible values is from 2 to 2^n-1.
Your remaining problem is to determine which of the remaining locations can contain that 6th-largest element.
Draw a tree of the proper depth -- better yet, do this only 4 levels deep, and work with the 4th-largest element. Say, use 99, 98, 98, 96, and then the "other" values can be 1 through 11. Is there anywhere on this tree you can put 96
that you cannot arrange the other numbers to form a legal tree?
Expand the tree one more level. Now where are the holes in which you cannot put 96
?
Does that get you un-stuck?