Question: Write the following pseudo code as Java Algorithm do Something(int[] A: an array of N integers) for(int i N/2; i >= 0; i--): foo(A, i)

Write the following pseudo code as Java

Write the following pseudo code as Java Algorithm do Something(int[] A: an

array of N integers) for(int i N/2; i >= 0; i--): foo(A,

Algorithm do Something(int[] A: an array of N integers) for(int i N/2; i >= 0; i--): foo(A, i) end for end doSomething procedure foo(int[] a, int i) int L 2*1+1 int r = 2+i+2 if I >= 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!