Complete the code to create a min heap by choosing the correct comparison operator.
if (heap->array[i] [1] heap->array[parent(i)]) { swap(&heap->array[i], &heap->array[parent(i)]); i = parent(i); }
In a min heap, the child node should be less than the parent node to maintain the heap property.
Complete the code to create a max heap by choosing the correct comparison operator.
if (heap->array[i] [1] heap->array[parent(i)]) { swap(&heap->array[i], &heap->array[parent(i)]); i = parent(i); }
In a max heap, the child node should be greater than the parent node to maintain the heap property.
Fix the error in the heapify function to maintain min heap property by choosing the correct comparison operator.
if (left < heap->size && heap->array[left] [1] heap->array[smallest]) smallest = left;
For min heap, we update smallest if left child is smaller than current smallest.
Fill both blanks to complete the condition that decides whether to swap in max heapify.
if (right < heap->size && heap->array[right] [1] heap->array[largest]) largest = [2];
In max heapify, if right child is greater than largest, update largest to right.
Fill all three blanks to complete the min heap insertion logic.
while (i != 0 && heap->array[parent(i)] [1] heap->array[i]) { swap(&heap->array[i], &heap->array[[2]]); i = [3]; }
In min heap insertion, swap while parent is greater than child, update i to parent index.
