From: mcc@entropy.cs.princeton.edu (Martin C. Carlisle)
Subject: Re: Huffman Encoding?
Date: 1999/04/05
Date: 1999-04-05T00:00:00+00:00 [thread overview]
Message-ID: <7eard5$djd$1@cnn.Princeton.EDU> (raw)
In-Reply-To: 3708B1B2.715FC009@bigfoot.com
Actually, at an undergraduate level (where we give a very similar assignment)
I would expect the students to understand a heap data structure.
It can be created in linear time (vice nlogn for comparison based sorts),
and allows extracting the minimum and inserting new items (both required for
Huffman [the standard algorithm for it anyway]) in logarithmic time.
With a linked list, you have O(n) insert, but O(1) extract min.
--Martin
ps. You can sort 5 elements in constant time.
In article <3708B1B2.715FC009@bigfoot.com>,
Roy Grimm <ragrimm@bigfoot.com> wrote:
>Mark wrote:
>>
>> I'm currently writing a program that produces Huffman Encoding for text
>> input. I'm trying to determine the best data structure to utilize for
>> sorting the character frequencies. I used a linked-list of records to
>method of storing the bounded list of character frequency in a data
>structure that had O(1) lookup time. I'll leave the implementation as
>an exercise for the reader.
>
>p.s. If you're looking to optimise space, there is a way to eliminate
>one field from your list of elements. That's an exercise for the
>advanced students...
>
>--
>Roy A. Grimm
>
>Mathematics and alcohol don't mix. Don't drink and derive.
--
Martin C. Carlisle, Asst Prof of Computer Science, US Air Force Academy
carlislem@acm.org, http://www.usafa.af.mil/dfcs/bios/carlisle.html
DISCLAIMER: This content in no way reflects the opinions, standards or
policy of the US Air Force Academy or the United States Government.
prev parent reply other threads:[~1999-04-05 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-05 0:00 Huffman Encoding? Mark
1999-04-05 0:00 ` Jerry van Dijk
1999-04-05 0:00 ` Roy Grimm
1999-04-05 0:00 ` Martin C. Carlisle [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox