Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I had a questions under the respective photos, thanks! Just wondering if you cou

ID: 3775367 • Letter: I

Question

I had a questions under the respective photos, thanks!

Just wondering if you could explain the above picture's algorithm? What is r and n?Why is the time O(lgn)?

Also,does this picture illustrate MAX-HEAPIFY?

Not sure about this algorithm of BUILD-MAX-HEAP, brief explanation?

Could the process in the above picture be explained in terms of the algorithm? I assume it is build max heap?

Heaps A max-heap is a nearly complete binary tree in which Value stored in root is greater than the values in the root's two child nodes Both subtrees of the root are max-heaps A tree with one node (or an empty tree) is a heap Represented as an array

Explanation / Answer

the input is : Array A (or binary tree) index i in array the preconditions required: the binary trees rooted at LEFT(i) and RIGHT(i) are heaps Note: A[i] may be smaller than its children the post conditions postcondition: The subtree rooted at index i is a heap MaxHeapify(A,i) l = LEFT(i) r = RIGHT(i) if l leq heap_size(A) and A[l] > A[i] then largest = l else largest = i if r leq heap_size(A) and A[r] > A[largest] then largest = r if largest eq i then swap(A[i],A[largest]) MaxHeapify(A,largest)