CSCI 1436 Fall 2019 Assignment 3

Instructions

Develop a menu-driven application to invoke functions for text compression according to the problem specification and design constrains specified below. 

 

Input

Choose either the keyword, run-length, or Huffman encoding data compression technique. Then enter the text to use for that choice of technique. For keyword encoding access a table of words and symbols to use when replacing a text word with a single character, and for Huffman encoding access a table of characters and variable-length bitstrings to represent those characters.

 

Text for testing

Keyword encoding:

“Speech encoding is an important category of audio data compression. The perceptual models used to estimate what a human ear can hear are generally somewhat different from those used for music. The range of frequencies needed to convey the sounds of a human voice are normally far narrower than that needed for music, and the sound is normally less complex.”

Plus a table of these words and symbols:

Word Symbol

an        ~

are     `

data     !

far     @

for     #

from     $

is     %

of     ^

the     &

to     *

 

b Run-length encoding: “AAAALLLiiiiionnnnnn is king”

c Huffman encoding: “CLEATS”

plus a table of characters and bit strings to replace those characters

character code

A     00

E     11

T     010

C     0110

L     0111

S     1000

 

 

Processing

For keyword encoding, replace words found in the text with a single character (e.g the word “from” would become “$”).

For run-length encoding, replace a long series of a repeated characters with a “flag-character” followed by the repeated character. Followed by a single digit that indicates how many times the character si repeated: “AAAALLLiiiiionnnnnn is king” would become: A*4LLLi*5on*6 is king and for Huffman encoding use the table above to produce a variable-length bitstring for a character string such as “CLEATS”.

 

Output

Output a descriptive program title. Have an input prompt for the compression technique to apply followed by the text to be compressed. Then, output the compressed text and the compression ratio.

Example output:

Text compression technique:

Compression codes: k. keyword, r. run-length, h. Huffman

Code choice? R

Original text: AAAALLLiiiiionnnnnn is king

Compressed text: A*4LLLi*5on*6 is king

Compression ratio: 21/27 or 0.77

 

Need a custom answer at your budget?

This assignment has been answered 2 times in private sessions.

© 2024 Codify Tutor. All rights reserved