# Questions and Answers on Homework Assignment #4

#### HW#4 due on paper in class, Monday 7 March 2011

Question text is in black, answers in blue.

• Question 4.1, posted 4 March: I don't know what is meant by "primes" in this problem, since we are talking about strings and not naturals.

Sorry, this could have been clearer in the book. For this problem, we have redefined the word "divides" to mean "is a substring of". With this definition, λ "divides" every string just as 1 divides every natural, and every string "divides" itself just as every natural divides itself. We define a positive natural to be prime if it is not 1 and the only naturals that divide it are 1 and itself. Similarly, we can now define a string to be "prime" if it is not λ and the only strings that "divide" it are λ and itself. Given this, you should be able to explain which strings are "primes" and prove that they satisfy the Atomicity Lemma.

• Question 4.2, posted 5 March 2011: The only way I can see to solve problem 3.5.5 is to follow the proof of the Chinese Remainder Theorem, which requires me to find the inverse of one number mod another. May I assume that a method for this inverse operation has already been defined, and just call it?

No, I would like your method for Chinese remaindering to be self-contained, so that you can actually run and test it. This means writing a method to find inverses, which is only a few lines if you get it right. You also need a method to test relative primality -- implementing the Euclidean Algorithm is pretty easy either with or without recursion.

• Question 4.3, posted 6 March 2011: Again on 3.5.5., is it all right if I have multiple methods in my solution, like one method to find gcd's, another to find inverses, and a third one to solve the original problem?

Of course, that is just better programming style. As long as you have one method that does the job required, of course it may call other methods that you have written.