



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solution to an assignment question about implementing a binary heap algorithm to find the maximum element in an array. the array and its corresponding index for parts (a) and (b) of the question, as well as the pseudocode for the algorithm in part (c).
Typology: Assignments
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Yes binary heap in part (a) is the same as the binary heap in part (b).
If left arr ==
return;
set max = arr[0]
set max_index=0;
for i>n
if arr[i]> max
set max_index=
set max =arr[i]
print max_index;
find_max_index(arr[],size,index,max_index)
if (index == size)
return max_index;
if(arr[index]>arr[max_index]
max_index=index;
return find_max_index(arr[],size,index+1,max_index)
find_max(arr,int l,int r)
if(left arr ==1)
{
return A[1];
}