CSE 2312 - Assignments

Not Graded Practice for Assignment 3

This is a set of practice questions. Feel free to work on these questions, and to ask questions if you face any difficulties in coming up with answers. While collaboration with others on the graded homework is strictly prohibited, you are free to work on these practice questions together with other people.

Since they are practice questions, you do not have to, and should not, submit answers to these questions on Blackboard. These questions will not be considered in any way towards your course grade. At the same time, based on the instructor's experience, individuals spending substantial and systematic effort in answering these practice questions by themselves tend to significantly improve their overall class performance.


Practice Question 1

Complete the program provided at general_codes.c to do encoding and decoding of binary strings using a code stored in a text file. Decoding will do error correction and error detection.

To make it easy to read and modify input and output files using a text editor, our input and output will be TEXT files, not binary files. As an example, consider 3-bit original word 100, and the code defined in file code1.txt, which defines a mapping of 3-bit original words to 6-bit codewords.

The program takes four command line arguments:

The program behaves as follows: You should assume that the input file ONLY contains only characters '0' and '1', nothing else (no spaces, new lines, etc.). You should enforce that your output file follows the same convention, and also contains ONLY characters '0' and '1'.

To help you get started, we provide the following resources:

While we have provided these test files, we will test your solutions with different test files, so your solution should be able to handle any valid code and input files.


Practice Question 2

When we transfer data from a big-endian machine to a little-endian machine, do we need to treat 16-bit and 32-bit integers the same way, or not? If not, what should be the difference? Describe how each of the two cases must be handled. Provide specific examples.


Practice Question 3

Suppose that we have an error-detecting code, mapping m-bit original words to n-bit codewords. Suppose that one n-bit codeword has been corrupted to a random n-bit pattern (so, we do not specify here the number of bits that were changed). What is the probability that this error will be detected, as a function of m and n?


Practice Question 4

(This is Problem 15 from Chapter 2 of the textbook).

An extended ASCII character is represented by an 8-bit quantity. The associated Hamming encoding of each character can then be represented by a string of three hex digits. Encode the following extended five-character ASCII text using an even-parity Hamming code: Earth. Show your answer as a string of hex digits.


Practice Question 5

(This is Problem 16 from Chapter 2 of the textbook).

The following string of hex digits encodes extended ASCII characters in an even-parity Hamming code: 0D3 DD3 0F2 5C1 1C5 CE3. Decode this string and write down the characters that are encoded.


Back to the list of assignments.