Re: An interview question.
From: Thomas Matthews (Thomas_MatthewsSpitsOnSpamBots_at_sbcglobal.net)
Date: 07/28/04
- Next message: Rowland: "Re: Organisation of C programs"
- Previous message: Thomas Matthews: "Re: fseek speed"
- In reply to: Matt: "An interview question."
- Next in thread: Arthur J. O'Dwyer: "Re: An interview question."
- Reply: Arthur J. O'Dwyer: "Re: An interview question."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 28 Jul 2004 14:30:54 GMT
Matt wrote:
> I was asked to compress a text file in a way that evey word be written
> with the number of times that such a word is repeated. Something like
> this:
>
> If this is the original file:
>
> ---------------------------------------
> AAAA BBB CCCC AAAA CCCC AAAA........
>
>
> the result will be:
> ---------------------------------------
> 3 AAAA
> 1 BBB
> 2 CCCC
>
>
>
> I appreciate any hints.
>
>
>
> Matt
One of the popular compression algorithm is based on this
technique. I think it might be Huffman, or start with an 'L'.
Perhaps somebody else will chime in. :-)
Essentially, the algorithm creates a table of patterns, then
if the pattern is repeated, writes out the index of the
pattern.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
- Next message: Rowland: "Re: Organisation of C programs"
- Previous message: Thomas Matthews: "Re: fseek speed"
- In reply to: Matt: "An interview question."
- Next in thread: Arthur J. O'Dwyer: "Re: An interview question."
- Reply: Arthur J. O'Dwyer: "Re: An interview question."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|