File Compression

This is a discussion on File Compression within the C++ Programming forums, part of the General Programming Boards category; Hey, Iím going to write a text compression program. Iíve attempted to make it relatively simple. Here is the algorithm ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    27

    File Compression

    Hey,

    Iím going to write a text compression program. Iíve attempted to make it relatively simple. Here is the algorithm I will use. Give me some feed back on if the algorithm is logical, and if you have additional ideas on how to increase compression while not increasing complexity significantly, please reply.

    To aid in explanation Im going to use a simple pretend text that I want to compress it is "hello the cat is on the big wall."

    1. Read a word from file.

    2. If the word is in the library then replace with number that corresponds to word.

    3. If the word is not in library then put it in the library and replace the word with a number that corresponds to word in library.

    4. Repeat 1-3 until file is completely read.
    (When the previous steps are finished the output will look something like:
    hello the cat is on big wall (note: word position defines number used to represent word)
    1 2 3 4 5 2 6 7
    5. Go through and look for numbers that are used only one time. When one is found delete that word from the list, and replace the representing number with the actual word.

    6. Find the most common number, move the word that corresponds to that letter to the beginning of the word list (for example: if "the" is the most common word and it is said 100 times, but it is represented by the number "11". Then changing the representing number to "1" will half the number of characters required for saying "the").

    Thank you,
    Gr3g
    Chance favors the prepared mind.

    Vis. C++ 6.0

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    It looks good to me. What do you plan to do when your word list becomes very large though? Perhaps if you were compressing Knuth's Art of Programming series. *grin*

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21