The First Home Assignment

Please, read carefully:

Published: March 7, 2000
Deadline: April 2 (Sunday), 2000, 24:00 hours

1. General Instructions:

Submit all your source code (including any documentation) and samples of input and output data in the printed form to my T.A. Roby Joehanes (MS 226).

In addition, submit all your source code via e-mail as an attachment to joehane@a.cs.okstate.edu. Use Assignment No. 1 in the subject field. It is a good idea to compress your attachment using a compression utility like pkzip.

You can use any common high-level programming language like C/C++, Pascal, Basic, Java, provided that the source code can be compiled, linked, and run on usual OSU platforms. If you are not sure, ask my T.A. Roby Joehanes (MS 226), joehane@a.cs.okstate.edu before you start your work.

Your program must be able to run on a.cs computers or on PCs. You should document how to compile and run your program (mentioning the compiler along with the switches).

Questions concerning the assignment should be sent by e-mail to the following address: zizka@a.cs.okstate.edu.

Questions concerning the submission should be sent by e-mail to the following address: joehane@a.cs.okstate.edu.

Homeworks delivered after the deadline will NOT be accepted in any case.

Important: When writing programs, apply a good programming style to your source code (use indents, comments, reasonable names of variables, constants, operators, data structures, functions, etc., so that someone else can easily read and understand your programs; a good programming style is a part of your solution and it will also influence the number of points you will get). Avoid any programming tricks. Avoid any cryptic and obscure coding. Always prefer readability and clarity. Remember: your results must be reproducible by other persons. If my T.A. cannot reproduce your results using your source code, you cannot obtain any points.

Place comments at the beginning of your program, so that it would be absolutely clear on which platform your program can run, which compiler you used and if you explicitly employed some switches. For example:

/*************************************************************************
Compiler: MS Visual C++ 6.0
Platform: MS Windows 98
Switches: None

(and anything important for compiling and running the program
by other people; e.g., information about input/output files, etc.).

**************************************************************************/

2. Homework Description:

Design, implement, debug, and submit a program, which can correct single-bit errors using Hamming code.

Step No. 1:

Write a subprogram named Hamming (a procedure, a function, or a method) which takes the following input parameters:

m ... a number of data bits per codeword;
r ... a number of parity bits per codeword;
w ... a string of characters that consists of m+r 1s and 0s, (e.g., 001110010100101010), that is, a codeword. Thus, each character represents one bit.

The task of your subprogram Hamming is to correct single-bit errors provided that the even parity is used. If the input string is correct, Hamming returns it with no changes. If the input string contains a single-bit error, Hamming returns a corrected string.

Step No. 2:

Design and create an ASCII text file named iString.txt, which consists of 5 different correct and 5 different incorrect codewords (strings). Each string has m=16 data "bits" and r=5 parity "bits"; that is, each string consists of 16+5=21 characters. The first line contains m and r. Each string is on a separate line, i.e., the file consists of 11 lines. This file will be used for testing your subprogram Hamming.

An example of the test file (just a part of each string is shown):

16 5
001101 . . . 110101
100010 . . . 100100
.
.
.
101010 . . . 010010

Step No. 3:

Design and implement a program, which reads the input parameters m and r as well as the input "bit" strings. The program calls your Hamming subprogram for each input string to make sure the codewords are correct. After receiving a string from Hamming, the program writes into an output ASCII text file the original string, two spaces, and the string returned by Hamming. Both the original and the returned strings are placed on one line. The output file name is oString.txt and it should contain 10 lines.

An example of the output file:

001101 . . . 110101 001101 . . . 110101
100010 . . . 100100 101010 . . . 100100
.
.
.
101010 . . . 010010 101010 . . . 010000

Step No. 4:

Compile, link, and run your program using the input test file iString.txt. Check the results in the output file oString.txt.

Step No. 5:

Submit your results before the deadline.