Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following program needs to be in c. I need guidlines/advice on how to make the above program, as someone who does not understand bitwise

The following program needs to be in c. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
I need guidlines/advice on how to make the above program, as someone who does not understand bitwise operators.
Your program cannot use string functions to construct your code words; it must use a short int and bitwise operators to manipulate bits of the short int codewords. In this lab, each student is to write a prompt-driven program called p3.c that encodes a text string using Huffman Encoding. The student should gain an understanding of: - Storage Types and Binary Representations - Bitwise Operators: AND, OR, and Shifting - Efficiently Storing Non-byte-size Values - Formatted Input and Output Strings - Displaying Binary, Octal and Hexadecimal values Background Huffman Encoding is a lossless compression technique which takes a string of symbols with a known symbol probability and uses those probabilities to produce new symbols whose variable length is determined by the frequency of occurrence of each symbol (like a similar but much improved Morse Code). When the new symbols are transmitted in a system with the given symbol probabilities, it will produce minimal length transmission sequences. For this project you will be given the Huffman code assuming the following symbol probabilities for English text: Input The program should prompt the user to enter whether they wish to encode or decode data. If encoding is desired, the program should ask the user to input a string only of Alphabetic characters terminated with a special EOT symbol, ' [ ', with a maximum length of 64 characters. All non-alphabetic symbols should be ignored, and all lower-case letters should be converted to upper case. If decoding is desired, the program should ask the user to input a string of Hexadecimal characters, ' 0 ' to ' F '. with a maximum length of 64 characters. The program should continue to input and encode strings until the string 'qui t ' is input. Encoding Operation The input string should be encoded using the following Huffman code symbols: symbo1 A: 0001 Symbol J. 11001011 Symbol 5: 1000 Bynbol 1: 001111 Bymbel Xi 1100100 symbel Ti 111 3ynbol 1 H: 1001 symbel a: 1100101000 symbol a: 1100101010 syntbo1 i: 0100 symbol a: 1010 symbol not:1200102011 Note: The order of these codeword bits is very important. To properly distinguish and decode a group of symbol bits, they must be read from left to right. That is an ' A ' should be decoded by reading in order 0-0-0-1. The character codes above must be stored one after another in an array of 16-bit integers, with all bits being used to store code bits. The resulting code should be stored in the minimum number of integers - not one letter integer. Therefore, some code symbol's bits will be stored in two different integers, where indexing the word and bits in the word will be necessary. For example, if the first three letters of the input data were "XYZ [" they should be stored as: The first integer of the code, Codeword [0], should contain the number of code integers used to store the code (excluding this first integer.) Notice that the difficulty in this program is simply that the Huffman code is not an equal-length code. Therefore, code symbols will spread across the natural byte boundary of the computer. Output The program should echo the string entared and then display the binary, hexadecimal, and octal values of each codeword integer which includes an EOT symbol, "[ ", as shown below. Example Output After the user is prompted for string to encode, Enter String: Clemson Tigers! the program should display the following information: String to Zncode: CraMsokrIGERS Codeword [0]=4 Codeword [1]=0111101000001101 07AOD0075015 Codeword [2]=1110100100000100 0x89040164404 Codeword [3] =0111000110000101 071850070605 Codeword [4]=1101010011000101 0DC50152305 Note, the location of each character in the codeword string is shown below: Codeword [1]=0111101000001101M E. L C Codeword [2]=1110100100000100T H O S. Codeword [3]=0111000110000101R B G I T Codeword [4]=1101010011000101 [ SR Below, I have the Hexadecimal and then the Octal groupings denoted for your penusal. Codeword [1]=0111101000001101. 07 AOD 0075015 Codeword [2]=1110100100000100 0x89040164404 Codeword [3]=0111000110000101 071850070605 Codeword [4]=1101010011000101 0xD4C50152305 Codieword [1]=0111101000001101. 07 AOD 0075015 Codeword [2]=1110100100000100 039040164404 Codeword [3]=0111000110000101 071850070605 Codeword [4]=1101010011000101 01C50152305 Notice that it takes only eight bytes to store this string. whereas it takes fourteen in ASCI, but of course, it's much "uglier" since the codewords are not equal sizes. Decoding Operation The programmer can assume that the string of characters input has been encoding using the method above. The program should input the hex characters as an array of sixteen-bit values, groups of four characters, as given above. Therefore, if the string input is "7AODE9047185D4C5", the program should store the characters as Codeword[0] =0111101000001101 Codeword [1]=1110100100000100 Codeword[2] =0111000110000101 Codeword[3] =1101010011000101 The codewords should then be decoded using the codewords above in order to produce the output string Decode string = "CLEMSONTIGERS" Remember that the code bits are store from least to most significant bits, e.g. the codeword for ' L ' is 00001 and is stored in b4b3b2b1b0 as 10000 , as shown above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago

Question

What is Ohm's law and also tell about Snell's law?

Answered: 1 week ago

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago