[Python-Dev] Priority queue (binary heap) python code

Delaney, Timothy tdelaney@avaya.com
Mon, 22 Jul 2002 09:40:24 +1000


> From: Kevin O'Connor [mailto:kevin@koconnor.net]
> On Sat, Jul 20, 2002 at 02:06:29AM -0400, Guido van Rossum wrote:
> 
> >The only change I would make would be to make heap[0] the
> > lowest value rather than the highest.
> 
> I agree this appears more natural, but a priority queue that pops the
> lowest priority item is a bit odd.

I'm in two minds about this. My first thought is that the *first* item
(heap[0]) should be the highest priority.

OTOH, if it were a sorted list, list[0] would return the *lowest* priority.

So i think for consistency heap[0] must return the lowest priority.

Tim Delaney