質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top