Vra

I've implemented a minHeap class so I am curious if, without modifying the code, it would be possible to use the minHeap class as a max heap?

Was dit nuttig?

Oplossing

Just flip the sign of all your values before you put them into the heap, and again as you take them out of the heap.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top