Huffmancodes

Assignment Help Data Structure & Algorithms
Reference no: EM13761744

  • Huffman Codes

You will turn in one file: HuffmanCodes.java, which can encode and decode files using Huffman codes. The program has the following command-line interface:

$ javaHuffmanCodes --help
Usage: java HuffmanCodes OPTIONS IN OUT
Encodes and decodes files using Huffman's technique

-e, --encode encodes IN to OUT
-d, --decode decodes IN to OUT
--show-frequency show the frequencies of each byte
--show-codes show the codes for each byte
--show-binary show the encoded sequence in binary
-h, --help display this help and exit

• When the encode option is used, the program will read in the file specified by the IN operand and create the file specified by the OUT operand. Depending on the nature of the input file, the output file could be smaller than the original input.

• When the decode option is used, the program will read in the file specified by the IN operand and interpret it as the output from the encode operation. If the given file represents a valid encoding, the original encoding for the file will be restored in a new file, specified by the OUT operand.

  • Frequency Counting

The show-frequency option assists debugging. When it is set, the frequency table computed from the input file is output during the encoding process. For example, if the input file is the characters "mississippi" (without a newline), then the output would be:
$ echo -n "mississippi" > mi.txt
$ javaHuffmanCodes --encode mi.txt mi.encoded --show-frequency

FREQUENCY TABLE
'm': 1
'p': 2
'i': 4
's': 4

input: 11 bytes [88 bits]

output: 12 bytes [header: 71 bits; encoding: 21 bits]
output/input size: 109.0909%

The first column is each byte of the input file displayed in the format of a Java character literal (e.g., the newline character would be represented as '\n'). The second column is the count (in decimal) for the number of times that byte's value is present in the input file.
The table is ordered from least frequent to most frequent, with ties broken by each byte's value.

  • Generating Prefix-Free Codes

Like the show-frequency option, the show-codes option also assists debugging. It displays the variable-length Huffman codes for each value, using a sequence of "0" and "1" characters.
$ javaHuffmanCodes --encode mi.txt mi.encoded --show-codes
CODES
"0" -> 's'
"11" -> 'i'
"100" -> 'm'
"101" -> 'p'

input: 11 bytes [88 bits]

output: 12 bytes [header: 71 bits; encoding: 21 bits]
output/input size: 109.0909%

  • Encoding the Sequence

Although you should also be using the xxd command to help you view your file contents in binary, it is also helpful to have an explicit show-binary option to describe the sequence:
$ javaHuffmanCodes --encode mi.txt mi.encoded --show-binary

  • ENCODED SEQUENCE

100110011001110110111
input: 11 bytes [88 bits]
output: 12 bytes [header: 71 bits; encoding: 21 bits]
output/input size: 109.0909%

  • Decoding

The program will also decode sequences:
$ xxd -b mi.encoded
0000000: 00000000 00000000 00000000 00001011 01011100 11001011 ....\.
0000006: 01101101 11000010 11010011 00110011 00111011 01110000 m..3;p
$ javaHuffmanCodes --decode mi.encodedmi.restored --show-codes

  • CODES

"0" -> 's'
"11" -> 'i'
"100" -> 'm'
"101" -> 'p'
original size: 11
$ catmi.restored
mississippi

Reference no: EM13761744

Questions Cloud

Can occur with the perceiver in the perception process : Define and describe three common problems that can occur with the perceiver in the perception process. Identify and describe three different learning methods an organization can use to train its associates.
Define a good design process and incorporates sequential : Design a program that will allow a user to Input a list of his Classmatess along with their Gender(Male, Female), Age and City where they reside. You must first collect all the information from the user. Then determine and print the average age of..
Sales and purchase-related transactions : Problem 1: The following selected transactions were completed during June between Snipes Company and Beejoy Company:
Differences between an outpatient and an inpatient record : Compare and discuss the differences between an outpatient and an inpatient record. In your discussion, identify the differences in content and explain why these differences are necessary
Huffmancodes : You will turn in one file: HuffmanCodes.java, which can encode and decode files using Huffman codes. The program has the following command-line interface:
Microsoft jumps into the growing market : Article- Microsoft Jumps Into the Growing Market for Wearable Fitness Technology. Summary of two pages of this article
Astronomical objects based problems : Find 2 good pictures or videos of features in the solar system.
Explain what is normalization : In what business database environments is denormalization appropriate and why. What would denormalization specifically involve. What is normalization
Advantages and the advantages of dynamic pricing : What are the advantages and the advantages of dynamic pricing to the companies that use it? To the customers of the companies that use it?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd