Vidyalelo
Data Structure · Q95

Heaps

Programming · Data Structure · question 95

Q95

For construction of a binary heap with property that parent node has value less than child node. In reference to that which line is incorrect. Line indexed from 1. 1. add(int k) 2. 3. heap_size++; 4. int i = heap_size - 1; 5. harr[i] = k; 6. while (i != 0 && harr[parent(i)] < harr[i]) 7. 8. swap(&harr[i], &harr[parent(i)]); 9. i = parent(i); 10. 11.

A.
Line - 3
B.
Line - 5
C.
Line - 6
Answer
D.
Line - 7

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board