Docsity

Lab 6: Implementing Huffman Codes and Heaps for Text Compression - Prof. Olac Fuentes, Lab Reports of Data Structures and Algorithms

Toggle sidebar
bg1
1
CS2402
Spring 2009
Lab 6
Huffman Codes and Heaps
Due Friday, April 3, 2009
Instructions
Write a program that implements Huffman codes to compress text.
1. Use a large text file to compute the frequency of each character.
2. Apply Huffman’s algorithm to build the optimal compressing tree. In order to find the trees
with minimum weight efficiently, use a heap (with the modification that the root now will
contain the smallest element).
3. Compress and the text using your codes.
4. Use your codes to decompress the text, making sure that you obtain the same text you
provided as input.
You are NOT allowed to use the Java built-in implementations of heaps or Huffman codes. Test
your methods using the same text files you used for labs 4 and 5.

Partial preview of the text

Download Lab 6: Implementing Huffman Codes and Heaps for Text Compression - Prof. Olac Fuentes and more Lab Reports Data Structures and Algorithms in PDF only on Docsity!

CS

Spring 2009

Lab 6

Huffman Codes and Heaps

Due Friday, April 3, 2009

Instructions

Write a program that implements Huffman codes to compress text.

  1. Use a large text file to compute the frequency of each character.
  2. Apply Huffman’s algorithm to build the optimal compressing tree. In order to find the trees with minimum weight efficiently, use a heap (with the modification that the root now will contain the smallest element).
  3. Compress and the text using your codes.
  4. Use your codes to decompress the text, making sure that you obtain the same text you provided as input.

You are NOT allowed to use the Java built-in implementations of heaps or Huffman codes. Test your methods using the same text files you used for labs 4 and 5.