Question: Im trying to defines a max-heap. Each node in the max-heap contains a process in a call called Maxheap, so far I have psedou code

Im trying to defines a max-heap. Each node in the max-heap contains a process in a call called Maxheap, so far I have psedou code

MaxHeapify( A, i)

l = left(i);

r = right(i);

if l <= A.heapSize and A[l] > A[i]

largest = l

else largest = i

if r <= A.heapSize and A[r] > A[largest]

largest = r

if largest != i

exchanged A[i] with A{largest]

MaxHeapify(A, largest)

}

buildAMaxHeap(A){

A.heapSize = A.lenght

for i = (a,lenght/2) downto 1

MaxHeapify(A,i)

}

How would I use MaxHeap to creat PQueue.java? (defines a priority queue using a max-heap.)

What other methods would I need in each class?

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!