prog1 - Data Structures and Algorithms (CS 130b) Prof. Suri...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Data Structures and Algorithms (CS 130b) Prof. Suri Programming Assignment 1 Handed Out: Jan 19 Due: Feb 2 1 Overview For the first programming assignment, you will implement the Huffman coding algorithm in C++ or C. In the UNIX tradition, you will implement the assignment as four separate pro- grams, each of which does a specific simple task. The programs are designed to communicate with each other via files and pipes. The four programs are: 1. frequencies – prints a table of the occurrence frequencies of characters in data read from stdin . 2. huffman – reads a frequency table from stdin , calculates and prints a table of Huffman codes for each character. 3. encode – using a table of Huffman codes (as generated by huffman ), translates data from stdin to the corresponding binary encoded data and prints it to stdout . 4. decode – using a table of Huffman codes (as generated by huffman ), translates encoded data from stdin back to the original data and prints it to stdout . You will be given a set of Perl scripts which implement the same functionality as your programs should. You may use these scripts as a black-box reference to play with and to understand how the programs should work. However, the behavior of your programs need not be identical to the reference scripts in order to be correct. 2 Details 2.1 frequencies [10 points] The frequencies program takes a sample text as input and outputs a table of character frequencies when the input is done. It should handle arbitrary (possibly binary) input and it should output the table with one line per character, containing the ASCII code for the character followed by some whitespace (preferably a tab) and then the number of occurrences of the character in the input, formatted as a human-readable number. Characters which don’t occur should not be listed. Other than reordering of the lines and padding your numbers with
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/23/2010 for the course MATH 104b taught by Professor Ceniceros,h during the Spring '08 term at UCSB.

Page1 / 4

prog1 - Data Structures and Algorithms (CS 130b) Prof. Suri...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online