CMPSCI 250: Introduction to Computation

David Mix Barrington

Spring, 2005

Homework #6 Questions and Answers

Question 6.4, 19 April 2005

In the draw poker question, may I assume that when the player draws three cards to her pair, she had a one-pair hand, that is, the three cards she discards are different ranks and none of them is the same rank as her pair?

Yes, this is exactly what is meant in the problem. Actually, if it helps clarify matters you may assume "without loss of generality" that she starts with two aces, a two, a three, and a four, and discards all but the two aces.

When you figure out her chance of getting three of a kind, remember that a full house is a separate case and not considered to be three of a kind. With the AA234 hand mentioned above, to get three of a kind her three new cards must consist of exactly one of the two aces, and two of the 45 non-aces. Furthermore, these two non-aces may not be the same rank as each other or she has a full house. And the number of ways for these two non-aces to be a pair is different for the ranks 2, 3, and 4 (which have three cards each in the deck) and the ranks 5 through K (which have four cards each in the deck).

Remember that there are two distinct ways to get a full house in this situation -- draw a third ace and a pair of something else, or draw three cards that are all of the same rank.

Question 6.3, 18 April 2005

On Page 6-44, I think there's a problem with Figure 6-17. Shouldn't the two strings at the first level be "a" and "ab", and shouldn't all the strings except λ start with "a"?

Yes, the right child of the root in each tree should be "ab" rather than "b", and every string in the right subtree of each tree should have an additional "a" at the beginning. This has been added to the errata page.

Question 6.2, 17 April 2005

On page 6-43, where is says that |a*baa*ba*| is (n choose 2), this doesn't seem to be right. For example, there is only one length-3 string in that language, bab, but (3 choose 2) is 3, not 1. Is there some mistake? The right answer seems to be (n-1 choose 2).

Yes, there are two mistakes here -- the second "a" is a typo and I left out the subscript "n" on the absolute value signs. It should say that |a*ba*ba*|n = (n choose 2).

Question 6.1, 16 April 2005

This isn't about the homework, really, but it's a problem that I found on the website. If b is a power of a (both are postive naturals), for any natural n an - 1 divides bn - 1. The problem is to prove the converse -- if an - 1 divides bn - 1 for all n, then b must be a power of a.

This was an interesting problem, thanks! The web site says it was from a Russian math olympiade, which means that it's hard but doesn't use very advanced math (sort of like the problems on the UMass math department's Jacob Prize test).

I haven't solved it yet, but here is some progress. First, it's not possible that b has a prime factor p that doesn't divide a. This is because if p divides b, then bn - 1 is congruent to -1 modulo p, for any n. However, if p doesn't divide a, then there must be some n such that an is congruent to 1 modulo p, and this gives us a contradiction.

Why must there be such an n? This uses a little more number theory than we did in the course (it is in the book in the second half of Chapter 3). For any prime p, and for any number a that is not divisible by p, ap-1 is congruent to 1 modulo p, so we can use p-1 as our n.

This is enough in the case where a is prime. If a is a prime power pe, then the above implies that b must be a power of the same prime, pf. But if you look at pf modulo pe - 1, you can see that it is 1 if and only if e divides f, which is true if and only if b is a power of a.

I haven't yet been able to solve the case where a is 6, the smallest number that is not a prime power. But here is one idea that may be useful...

Since we know that b has only the same prime factors as a, we can write b as aic where c is not divisible by a. Since a-1 divides b-1 = aic - 1, it also divides aic - 1 - (a-1)ai-1c = ai-1c - 1. Applying this operation repeatedly to reduce the power of a to 0, we find that a-1 divides c-1. This means that c must be greater than a. In the same way, we can prove that for any n, an - 1 divides cn - 1. So we've reduced the original problem to one where b is not divisible by a, but has only prime factors that are factors of a...

Last modified 19 April 2005