Deitel and Deitel Book...

Brett g Porter BgPorter at NOartlogicSPAM.com
Fri Mar 15 10:01:05 EST 2002


"James T. Dennis" <jadestar at idiom.com> wrote in message
news:a6rk1v$oac$1 at news.idiom.com...
> Dean Goodmanson <ponderor at lycos.com> wrote:
>
>  One of his examples implements a priority queue by treating a list as a
"heap"
>  (his term); his example takes over 50 lines of code and he doesn't
clearly show
>  sample usage of this class.  After awhile I abandonned my pondering of
his code
>  and wrote my own from scratch (as a dictionary of queues with a list of
the
>  keys to sort into priority order).

Actually, 'heap' is the correct word (assuming that he's using it in the
correct way -- don't have the book in question) and most algorithms texts
will implement priority queues in terms of heaps. When inserting single
elements into a priority queue, it's (IIRC) the most efficient
representation, requiring O(log n) comparisons and exchanges.







More information about the Python-list mailing list