How do you do this question and why is the answer D?

Answer:
D. (while i>=2 && lessthan(item, items.get(i/2))
{
items.set(i, items.set(i/2);
i /= 2;
}
Explanation:
This is a heap data structure.
Heap can be like:
0
1 2
3 4 5
which is represented in list as = [0,1,2,3,4,5]
Hence, heap is a tree type of data structure.
// repairs the heap by moving the last leaf to the right place.
private reheapUp()
{
int i =items.size()-1;// index of last leaf
Object temp = items.get(i);
(while i>=2 && lessthan(temp, items.get(i/2))
{
items.set(i, items.get(i/2);
i /= 2;
}
items.set(i, temp);
}
And seeing the structure of heap tree data structure, the D option as mentioned above looks correct.
As i=5
Object.temp =items.get(5);
(true && lessthan(5,3))
{
items.set(5, temp)
and temp = 5. And hence 5 is set to 5, and so on (please check next loop with i /=2 => i=2.5=3
And hence, D is the correct option for this question.