On Apr 4, 7:05 am, [EMAIL PROTECTED] wrote:
> My book says that in a heap, a value at position i will be than the
> values at positions 2*i and 2*i + 1.
>
> >> I am sure your book either uses 1-based arrays or a 0-based arrays
> >> with the first not used. The need to kee
My book says that in a heap, a value at position i will be than the
values at positions 2*i and 2*i + 1.
>> I am sure your book either uses 1-based arrays or a 0-based arrays
>> with the first not used. The need to keep these alternatives in mind
>> is an unfortunat
skip> Check the heapq docs for the constraints the Python heapq module
skip> maintains:
s/constraints/invariants/
Skip
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 3, 10:30 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
> <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> |
> |>> My book says that in a heap, a value at position i will be smaller
> |>> than the values at positions 2*i and 2*i + 1.
>
> I am sure your book either uses
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
|
|>> My book says that in a heap, a value at position i will be smaller
|>> than the values at positions 2*i and 2*i + 1.
I am sure your book either uses 1-based arrays or a 0-based arrays with the
first not used. The need to
On Apr 3, 5:27 pm, [EMAIL PROTECTED] wrote:
> >> My book says that in a heap, a value at position i will be smaller
> >> than the values at positions 2*i and 2*i + 1.
>
> Check the heapq docs for the constraints the Python heapq module maintains:
>
>http://docs.python.org/dev/lib/modu
>> My book says that in a heap, a value at position i will be smaller
>> than the values at positions 2*i and 2*i + 1.
Check the heapq docs for the constraints the Python heapq module maintains:
http://docs.python.org/dev/lib/module-heapq.html
They are different than what you stat
My book says that in a heap, a value at position i will be smaller
than the values at positions 2*i and 2*i + 1. To test that, I ran
this program:
--
from heapq import *
from random import shuffle
data = range(10)
shuffle(data)
heap = []
for n in data:
heappush(heap, n)
print heap