Ask Question, Ask an Expert


Ask Computer Engineering Expert

Huffman Coding based Compression Library

Huffman code is used to compress data file, where the data is represented as a sequence of characters. Huffman's greedy algorithm uses a table giving how often each character occurs; it then uses this table to build up an optimal way of representing each character as a binary string. We call the binary string the codeword for that character. A property of Huffman code is that it is a prefix code, i.e., in Huffman coding, no codeword is a prefix of some other codeword. The advantage of prefix code is that it makes decoding easier, as we do not need to use delimiter between two successive codewords. Given the frequency of each of the character, we can devise a greedy algorithm for finding the optimal Huffman codeword of each of the characters. For details of the greedy algorithm, INTRODUCTION TO ALGORITHMS 3rd edition by CORMEN please read Section 16.3 of the textbook.

In this assignment, we will build a compression library that compress text files using Huffman coding scheme. This library will have two programs: compress, and decompress; compress accepts a text file and produces a compressed representation of that text file; decompress accepts a file that was compressed with the compress program, and recovers the original file.


Input to the compress is a text le with arbitrary size, but for this assignment we will sippose that data structure of the file fits in the main memory of a computer. Output of the program is a compressed representation of the original file. You will have to save the codetable in the header of the compressed file, so that you could use the codetable for decompressing the compressed file. Input to the decompress is a compressed file, from that the program recovers the original file. For sanity check, you must have a specific magic word at some position in the header of the compressed file, so that decompress can recognize whether the given file is a valid Huffman compressed file.

You must pay attention to the following issues:

The file that we would use for testing can be very large, having size in Gigabytes, so make sure that your program is bug-free and it works for large input file.

prepare efficient algorithm, we will take off as much as 20 points if we feel that the program is taking unusually long time.

You must make sure that your program runs on a Linux Machine, and identically follows the formatting instructions. For formatting error, as much as 15 points can be taken off .

You should provide a Make file to compile your programs. Also, a README.txt file must be provided that will have the instruction to compile and run the programs.

Command-Line options


C++:  ./compress  -f  myfile.txt  [-o  myfile.hzip  -s

Java:  sh  -f  myfile.txt  [-o  myfile.hzip  -s]


C++:  ./decompress  -f  myfile.hzip[-r  -v]

Java:  sh  -f  myfile.hzip  [-o  myfile.txt  -s]

The command-line options that are within the square bracket are optional. The option \-f" precedes the input le name, which always has a .txt extension. The \-s" option prints statistics, such as for compression it prints, how many distinct characters are there, what is the compression ratio, and the wall clock time that it took for performing the compression task. For decompression, it prints how many character were written, and the wall clock time it took for performing the decompression task. The \-o" option precedes the name of an output le. If the output file name is not given, then we will append .hzip at the end of the input filename to create the output filename.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91171

Have any Question? 

Related Questions in Computer Engineering

1 in wireshark go to statistics gt summary what is the

1 .In Wireshark, go to Statistics > Summary. What is the Average Mbps? 2. Go to Statistics > Protocol Hierarchy. Which protocols use most of the bandwidth? 3. Go to Statistics > Packet Lengths > Create Stat. What percent ...

Assume that you have been hired to manage a large domestic

Assume that you have been hired to manage a large domestic and foreign information system. what are some of the issues and solution that you would discuss and plan.

Amicable numbers are pairs of numbers each of whose

Amicable numbers are pairs of numbers each of whose divisors add to the other number. (Note: 1 is included as a divisor but the numbers are not included as their own divisors.) Design and implement an algorithm that test ...

Describe the six steps you should follow when creating an

Describe the six steps you should follow when creating an OO application. Why do you think it is important to complete the steps in the proper order? What results when they are not in the proper order? After your initial ...

Design a tree deletion algorithm that handles left and

Design a tree deletion algorithm that handles left and right subtrees similarly. A variation on the right sub tree procedure should be used to also delete nodes in left subtrees. Figure 7.18 illustrates how your procedur ...

Term paper reengineering the course enrollment

Term Paper: Reengineering the Course Enrollment Process Consider Strayer University's current process of enrolling for courses through the use of the Web. Suppose that the University has contracted you to reengineer the ...

1 what is risk management why is the identification of

1. What is risk management? Why is the identification of risks, by listing assets and their vulnerabilities, so important to the risk management process? 2. According to Sun Tzu, what two key understandings must you achi ...

1 given an unsorted list of n values what is the

1. Given an unsorted list of n values, what is the time-complexity to find the k t h smallest value in the worst case? What would be the complexity if the list were sorted? 2. What is the O(·) for the findSortedPosition( ...

In this exercise we want to analyze some variants of key

In this exercise, we want to analyze some variants of key derivation. In practice, one masterkey kMK is exchanged in a secure way (e.g. certificate-based DHKE) between the involved parties. Afterwards, the session keys a ...

1 search your librarys database and the web for an article

1. Search your library's database and the Web for an article related to individuals violating their organization's policy and being terminated. Did you find many? Why or why not? 2. Go to the (ISC)2 Web site at www.isc2. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro