This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Saimadhav.Heblikar
Recipients Saimadhav.Heblikar, ezio.melotti, wchlm
Date 2014-04-09.08:23:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397031791.6.0.938564664367.issue21185@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,
I dont think its a bug. 
The textbook definition of a min(or max) heap is

"Heaps are binary trees for which every parent node has a value less than or equal to any of its children."

Therefore,
when lista = [1,6,5,4], and heapify is run on it,it can be viewed as
    1
  /   \
4  5  6

or [1,4,5,6]

When listb=[1,6,5], running heapify on it,gives
   1
  / \
 6   5

or [1,6,5]
heapify maintains the heap-invariant - Every key is smaller than its children. This invariant is not violated in the above example.

The heappop maintains the heap-invariant after popping. The line in your code
[heapq.heappop(listb) for i in range(len(listb))]
is the heapsort algorithm!.

Hopefully, this clears your question.
History
Date User Action Args
2014-04-09 08:23:11Saimadhav.Heblikarsetrecipients: + Saimadhav.Heblikar, ezio.melotti, wchlm
2014-04-09 08:23:11Saimadhav.Heblikarsetmessageid: <1397031791.6.0.938564664367.issue21185@psf.upfronthosting.co.za>
2014-04-09 08:23:11Saimadhav.Heblikarlinkissue21185 messages
2014-04-09 08:23:11Saimadhav.Heblikarcreate