views:

41

answers:

2

Possible Duplicate:
What do I use for a max-heap implementation in Python?

Python has a min heap implemented in the heapq module. However, if one would want a max heap, would one have to build from scratch?

A: 

You could multiply your numbers by -1 and use the min heap.

James Thompson
+1  A: 

No need to implement a max heap from scratch. You can easily employ a bit of math to turn your min heap into a max heap!

See this and this - but really this SO answer.

Matt Ball