Explore BrainMass
Share

Explore BrainMass

    Heapsort: Heapify

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Consider the following definition of HEAPIFY.

    HEAPIFY(A, i)
    1 l = LEFT(i)
    2 r = RIGHT(i)
    3 if l < heap-size[A] and A[l] > A[i]
    4 then largest = l
    5 else largest = i
    6 if r < heap-size[A] and A[r] > A[largest]
    7 then largest = r
    8 if largest != i
    9 then exchange A[i] and A[largest]
    10 HEAPIFY(A,largest)

    What is the effect of calling HEAPIFY(A, i) when the element A[i] is larger than its children?

    © BrainMass Inc. brainmass.com October 9, 2019, 7:00 pm ad1c9bdddf
    https://brainmass.com/computer-science/computer-systems-organization/heapsort-heapify-elements-104642

    Solution Summary

    It is a very brief answer, explaining the WHY of it as well.

    $2.19