Heaps & Priority Queues

Answer & solution
Official answer: B, C
Our answer: (n-1)/2 and (n-3)/2
Givens and goal
A binary minheap contains an odd number n>100 of entries in a 1-indexed array. Which positions are not leaves? A (n+1)/2; B (n−1)/2; C (n−3)/2; D n.
Approach
Use the array child-index formula; heap ordering by key value is irrelevant to the tree shape.
Step-by-step solution
1. For a node at position i, its left child would be at 2i and right child at 2i+1. A node is internal if at least the left child exists, which means 2i≤n.
2. Thus internal positions are 1 through floor(n/2); positions floor(n/2)+1 through n are leaves.
3. Write n=2k+1. Then floor(n/2)=k and the proposed positions become A k+1, B k, C k−1, D 2k+1.
4. Positions k and k−1 lie in the internal range. In particular k has children 2k and 2k+1. Positions k+1 and 2k+1 exceed the internal boundary and have no children.
5. Therefore B and C are not leaves. The condition n>100 ensures k−1 is positive and valid; the minheap property affects stored values, not this index boundary.