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
Get step-by-step solutions from verified subject matter experts
