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?
Asked
Active
Viewed 76 times
0
-
What language are you referring to? please add tags – Sean May 04 '14 at 10:46
-
@Sean: This seems like an algo question, thus language-agnostic. – Oliver Charlesworth May 04 '14 at 10:48
1 Answers
1
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.
Oliver Charlesworth
- 252,669
- 29
- 530
- 650