CS211 DATA STRUCTURES II
2ND COMPUTER SCIENCE & HIGHER DIPLOMA IN INFORMATION TECHNOLOGY
LABORATORY 5
Week Beginning 05/03/01
Mr. T Lysaght
HUFFMAN CODING
(You can download template files from the course homepage at:
http://www.cs.may.ie/~tlysaght/CS211/CS211Lectures.html.
- Build an optimal code tree using Huffman Coding with the following code symbols and associated probabilities.
|
SYMBOL |
PROBABILITY |
|
E |
0.1250 |
|
T |
0.0925 |
|
A |
0.0805 |
|
O |
0.0760 |
|
I |
0.0729 |
|
N |
0.0710 |
- Alter the classes TreeNode.java and BinarySearchTree.java by adding/altering class members and methods to implement Huffman coding. Rename the class BinarySearchTree.java as Tree.java, renaming constructors where appropriate.
- Save the class template files Path.java and Forest.java to the same directory as TreeNode.java and Tree.java. These files can be located at:
http://www.cs.may.ie/~tlysaght/CS211/CS211Lectures.html.
Add the appropriate code to these template class files.
- Write a driver program Huffman.java which constructs a code tree from the above symbols and probabilities. Print the code tree and symbols with their codes.