# CS4800 09F: Homework 02

Created: Sun 13 Sep 2009

Assigned: Wed 16 Sep 2009
Due: Wed 23 Sep 2009

## Instructions

1. Please review the course syllabus and make sure that you understand the course policies for grading, late homework, and academic honesty.

2. On the first page of your solution write-up, you must make explicit which problems are to be graded for "regular credit", which problems are to be graded for "extra credit", and which problems you did not attempt. Please use a table something like the following

Problem01020304 0506070809...
CreditRCRCRCECRC RCNARCRC...

where "RC" is "regular credit", "EC" is "extra credit", and "NA" is "not applicable" (not attempted). Failure to do so will result in an arbitrary set of problems being graded for regular credit, no problems being graded for extra credit, and a five percent penalty assessment.

3. You must also write down with whom you worked on the assignment. If this changes from problem to problem, then you should write down this information separately with each problem.

## Problems

Required: Do any 5 of the following 7 problems.
Points: Problems are worh 20 point each.
Unless otherwise indicated, problems are from Algorithms by Dasgupta, Papadimitriou, and Vazirani.

1. Problem 1.19
2. Problem 1.20 - Show your work.
4. Problem 1.26 - Show your work and explain the steps involved.
5. Problem 1.45 a, b (Give pseudocode only.), d
6. Problem 1.46
7. Recursion and induction in binary codes

Digital transmission protocols transmit signals using binary codes. In order to minimize the effect of errors, it is often useful to select a code such that "similar" signals use "similar"' codewords.

One such code is a list of 2nn-bit strings in which each string (except the first) differs from the previous one in exactly one bit. Let us call such a list a twiddling list since we go from one string to the next by just flipping one bit.

Consider the following recursive algorithm for listing the n-bit strings of a twiddling list. If n = 1, the list is 0,1. If n > 1, first take a twiddling list of (n-1)-bit strings, and place a 0 in front of each string. Then, take a second copy of the twiddling list of (n-1)-bit strings, place a 1 in front of each string, reverse the order of the strings and place it after the first list. So, for example, for n = 2, the list is 00,01,11,10, and for n=3, we get 000,001,011,010,110,111,101,100. Prove by induction on n that
(a) every n-bit string appears exactly once in the list generated by the algorithm, and

(b) each string (except the first) differs from the previous one in exactly one bit.

### Switch to:

Harriet Fell
College of Computer Science, Northeastern University
360 Huntington Avenue #340 WVH,
Boston, MA 02115
Email: fell@ccs.neu.edu
Phone: (617) 373-2198 / Fax: (617) 373-5121
The URL for this document is: http://www.ccs.neu.edu/home/fell/CS4800/F09/Homework/hw.02.html 