@Shaik Masthan
Should the heap property be checked
Case – 1: After inserting each element
Case – 2: After the end of insertion of all elements
For the given question both cases give same answer.
Eg: Consider the following array of elements
$7,6,5,4,3,2,1$
The minimum number of interchanges needed to convert it into a min-heap is?
Case 1 and 2 are giving different number of interchanges.
What should be the answer?
Case 1 or Case 2 or min(Case1, Case 2)?