Question: This algorithm is a Max Heap algorithm using an array. Please give an array example of: a) Size 15 for a best-case scenario for this

This algorithm is a Max Heap algorithm using an array.

This algorithm is a Max Heap algorithm using an array. Please give

Please give an array example of:

a) Size 15 for a best-case scenario for this algorithm.

b) Size 15 for a worst-case scenario for this algorithm.

Algorithm do something(int[] A: an array of N integers) for(int i = N/2; i >= 0; i--): foo(A, 1) end for end doSomething procedure foo(int[] a, int i) int L = 2*1+1 int r = 2*i+2 if ( >= A.Length && r >= A.Length: return if r >= A.Length && A[i] A[L] && A[r] > A[i]: swap A[i] and A[r] foo(A, r) else if A[L] > A[i]: swap A[i] and A[L] foo(A, L) end foo

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!