Problem Solving and Computing (CSC-103 98S)

[Instructions] [Search] [Current] [Changes] [Syllabus] [Handouts] [Outlines] [Journal] [Problems] [Computing] [SamR Docs] [Tutorial] [API]

# Problem Set 9: Coding Problems

Assigned: Tuesday, April 14, 1998
Due: Tuesday, April 21, 1998

The first few problems today come from an area of mathematics known as Combinatorics. They are from a lecture given by Herb Wilf when he visited our campus. The first three problems deal with Gray Codes: a listing of items where two items next to each other in the list are quite similar. (For different problems we might have a different definition of two items being ``similar.'')

1. Counting Subsets

[From the notes of Herb Wilf, transcribed by Emily Moore.]

Start with the set of numbers {1, 2, 3, 4, 5, 6} and find all 4-element subsets. List them in some organized fashion so you know you have all of them. How many are there?

2. Arranging Subsets

[From the notes of Herb Wilf, transcribed by Emily Moore. Modified and extended by Sam Rebelsky.]

A Gray code ordering of a set of subsets is a listing of the subsets so that a subset can be created from the immediately previous subset by replacing exactly one of the elements. For instance, A:{1,2,3,4} could be next to B:{1,3,4,5} since to get from A to B, we simply replace the 2 with a 5. Similarly, both A:{1,2,3,4} and B:{1,3,4,5} could be next to C:{1,3,4,6} since we can get from A to C by replacing the 2 with a 6 and from B to C by replacing the 5 with a 6. However, A:{1,2,3,4} and D:{3,4,5,6} are not next to each other since we would need to replace two elements in A in order to read D.

In this problem, you will work with four-element subsets of S:{1,2,3,4,5,6}.

A. List all of the potential neighbors of {1,2,3,4}.

B. How many such neighbors are there?

C. Is there a subset with fewer neighbors? More?

D. Find a Gray code listing of all of the four-element subsets of S:{1,2,3,4,5,6}.

3. Coding Binary Strings

[From the notes of Herb Wilf, transcribed by Emily Moore. Modified and extended by Sam Rebelsky.]

It is possible to apply Gray code techniques to "strings" of characters as well as sets. Consider the set of strings of length three in which all the characters in the string are 0 or 1. These are typically called binary strings. (Binary means "two-valued".)

B3: { 000, 001, 010, 011, 100, 101, 110, 111 }

The order in which they are listed here is called their natural order. If you think of these as binary numbers with place values from right to left of 1, 2, and 4, then the order is the order of their values 0, 1, 2, 3, 4, 5, 6, 7. For example, 111 is 4 + 2 + 1 = 7 and 010 is 0 + 2 + 0 = 2.

A Gray code order of these strings is a listing of the strings so that two strings next to each other differ only in one position. For instance, if we start with 000 the next string listed must have a single 1.

A. Find a listing of all eight strings in Gray code order.

B. Is there more than one such listing? If so, how many listings are there?

C. Find a listing of all sixteen length-four binary strings in Gray code order.

D. Can you generalize the pattern?

4. Error Detection

[Written by Sam Rebelsky. Based loosely on a problem by Emily Moore.]

As you may know, values in the computer are represented in as a sequence of binary (0/1) digits. Unfortunately, when values are transmitted, some digits may be flipped randomly. How do computers detect these errors? There are a number of ways. In general, we assume that at most one error is made in a string (that is, at most one digit is flipped from 0 to 1 or from 1 to 0).

Develop a set of three length-three strings of 0's and 1's such that it is impossible to convert one member of the set to another by flipping only one digit. For example, you shouldn't have both 010 and 011 in your set, since we can covert between the two by flipping one digit.

Is it possible to find a set of four length-three strings that have the same characteristics? Why or why not?

What is the biggest set of non-interconvertable length-four strings you can create?

5. Error Correction

[Written by Sam Rebelsky.]

As you may know, values in the computer are represented in as a sequence of binary (0/1) digits. Unfortunately, when values are transmitted, some digits may be flipped randomly. How do computers detect and correct these errors? There are a number of ways. In general, we assume that at most one error is made in a string (that is, at most one digit is flipped from 0 to 1 or from 1 to 0).

Develop a set of two length-three strings of 0's and 1's such that if zero or one changes are made in the string, then you can still tell which string it is.

To develop a coding in which we can not only detect but also correct errors, we will want to create a set of N length-M strings such that if zero or one changes are made to the string, then you can still tell which string was changed. If we use the term distance to indicate the number of bit flips necessary to convert one string to another, what is the minimum distance between any two elements in such a set?

Develop a set of eight strings of 0's and 1's such that if zero or one changes are made to any of the strings, you can still determine what the original string was.

Develop a set of eight strings of 0's and 1's such that if zero, one, or two changes are made to any of the strings, you can still determine what the original string was.

[Instructions] [Search] [Current] [Changes] [Syllabus] [Handouts] [Outlines] [Journal] [Problems] [Computing] [SamR Docs] [Tutorial] [API]

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.