473,661 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Huffman Compression

I am having a hard time making a Program in C/C++ that uses the Huffman
Compression to compress a file.

I have a file "Hello World" That i need to compress.

can someone please give me an example of how to do it with huffman
compression.

Nov 15 '05 #1
8 5641
di*****@gmail.c om wrote:
I am having a hard time making a Program in C/C++ that uses the Huffman
Compression to compress a file.

I have a file "Hello World" That i need to compress.

can someone please give me an example of how to do it with huffman
compression.


Sure. If you have not understood the algorithm -> comp.programmin g
If you have understood the algorithm: Show us your best shot at
it and describe your problems clearly and concisely.

If you expect to get your homework done by others: Ask somewhere else.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #2
di*****@gmail.c om writes:
I am having a hard time making a Program in C/C++ that uses the Huffman
Compression to compress a file.

I have a file "Hello World" That i need to compress.


I don't think you're going to be able to usefully compress "Hello
World". At most, you could reduce it by a few bytes.
--
"I should killfile you where you stand, worthless human." --Kaz
Nov 15 '05 #3
di*****@gmail.c om wrote:
I am having a hard time making a Program in C/C++ that uses the Huffman
Compression to compress a file.

I have a file "Hello World" That i need to compress.

can someone please give me an example of how to do it with huffman
compression.

http://justfuckinggoogleit.com/searc...ffman+coding+c

The task of filling up the blanks I'd rather leave to you. Feel free to
ask if you get stuck trying to implement the algorithm, but you'll
otherwise have to do your own homework.

S.
Nov 15 '05 #4
<di*****@gmail. com> wrote:
I am having a hard time making a Program in C/C++ that uses the Huffman
Compression to compress a file.

I have a file "Hello World" That i need to compress.

can someone please give me an example of how to do it with huffman
compression.


Try taking a look at this.

http://en.wikipedia.org/wiki/Huffman_coding
Nov 15 '05 #5
In article <87************ @benpfaff.org> bl*@cs.stanford .edu writes:
di*****@gmail.c om writes:
I am having a hard time making a Program in C/C++ that uses the Huffman
Compression to compress a file.

I have a file "Hello World" That i need to compress.


I don't think you're going to be able to usefully compress "Hello
World". At most, you could reduce it by a few bytes.


Without quotes Huffman reduces it from 88 bits to 32 bits (11 bytes to
4 bytes). With quotes from 104 bits to 40 buts (13 bytes to 5 bytes).
However, this excludes the table used...
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 15 '05 #6
"Ben Pfaff" <bl*@cs.stanfor d.edu> wrote in message
news:87******** ****@benpfaff.o rg...
di*****@gmail.c om writes:
I am having a hard time making a Program in C/C++ that uses the Huffman Compression to compress a file.

I have a file "Hello World" That i need to compress.


I don't think you're going to be able to usefully compress "Hello
World". At most, you could reduce it by a few bytes.


Easy. Here's some pseudo code:

If string = "Hello World" then x=1
write X
end

--
Mabden
Nov 15 '05 #7
"Mabden" <mabden@sbc_glo bal.net> writes:
"Ben Pfaff" <bl*@cs.stanfor d.edu> wrote in message
news:87******** ****@benpfaff.o rg...
di*****@gmail.c om writes:
> I am having a hard time making a Program in C/C++ that uses the Huffman > Compression to compress a file.
>
> I have a file "Hello World" That i need to compress.


I don't think you're going to be able to usefully compress "Hello
World". At most, you could reduce it by a few bytes.


Easy. Here's some pseudo code:

If string = "Hello World" then x=1
write X
end


Wow. You reduced it by...a few bytes.
--
"You call this a *C* question? What the hell are you smoking?" --Kaz
Nov 15 '05 #8
"Ben Pfaff" <bl*@cs.stanfor d.edu> wrote in message
news:87******** ****@benpfaff.o rg...
"Mabden" <mabden@sbc_glo bal.net> writes:
"Ben Pfaff" <bl*@cs.stanfor d.edu> wrote in message
news:87******** ****@benpfaff.o rg...
di*****@gmail.c om writes:

> I am having a hard time making a Program in C/C++ that uses the

Huffman
> Compression to compress a file.
>
> I have a file "Hello World" That i need to compress.

I don't think you're going to be able to usefully compress "Hello
World". At most, you could reduce it by a few bytes.


Easy. Here's some pseudo code:

If string = "Hello World" then x=1
write X
end


Wow. You reduced it by...a few bytes.


At most. Was there another part of the task that I missed?

I can do the same for the Bible, but I will have to move beyond
booleans... ;-)

--
Mabden

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5384
by: dot | last post by:
Hi all, I have written a Python huffman Encoding Module, for my own amusement. I thought it might be educational/entertaining for other people, so I've put it on my website and wrote about it a little. http://gumuz.looze.net/wordpress/index.php/archives/2004/11/25/huffman-encoding/ Your comments are highly appreciated! cheers,
8
8736
by: Sowen | last post by:
Hi, all I am wondering how to write bits by using ofstream? I have finished a huffman tree, but how can I write the bits to the file in order to gain compression? for example, 'A' returns a code '1101', what I should write? 13? no, I don't think so
47
3514
by: Bonj | last post by:
I downloaded the gzlib library from zlib in order to do compression. (http://www.gzip.org/zlib) The prototype of the compression function seems to be int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); It is meant to be called by C, but I would rather use it from C#. So I wrote the following C# program to test it, but it failed to work. The call to compress doesn't return or throw an exception, it simply...
8
9622
by: james | last post by:
I have ran into a little snag on an old database application I am converting. Out of 63 tables(all seperate files) , two of them are compressed using Huffman Compression. I have been searching all over the net (don't hit me too hard if you know a place I didn't look) and MSDN and cannot find anything that explains how to use Huffman in VB.NET. I need to extract the data on the fly from the files(tables) using Huffman and then put the data...
15
3681
by: aarklon | last post by:
Hi all, this is the program which I saw in my colleagues book. the program was run on turbo C++ 3.0 compiler /*beginning of header file huff.h*/ #ifndef _HUFF_H_ #define _HUFF_H_
4
5835
by: A_StClaire_ | last post by:
hi all, I'm trying to implement Huffman coding on letters of a string. I've written functions to define the initial leaf nodes (letters and their frequencies) and to sort them. I've also put together the actual tree with its appropriate nodes and child nodes. however I'm having some trouble developing a means of traversing the tree itself to create the binary key table. i.e., how would I know how many levels the tree has? this...
6
2911
by: Steve | last post by:
Hi, I've developed a testing application that stores formatted results in a database. Recently it was requested that I add the ability to generate graphs from the raw, un formatted test results (100,000+ float values) I don't intend to store all of the 100,000 datapoints, but rather a subset of say 250. Due to the volume of testing that we need and the volume of results stored, I need to be VERY careful with data size and keep things...
3
3623
by: Udhay | last post by:
Sir, I am udhay. I am a student and i am working on Audio compression for my exam. I want to know how does the compression take place in audio?? Can anyone suggest a link for the novice to go through the HUFFMAN Algorithm..
10
5689
by: Speed | last post by:
Hi, Could anyone tell me what is the simplest code to read a 8-bit grayscale JPEG image using C. Thanks a ton, Speed
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.