Exercises 1.1
1. Do some research on al-Khorezmi (also al-Khwarizmi), the man from whose name the word “algorithm” is derived. In particular, you should learn what the origins of the words “algorithm” and “algebra” have in common. 2. Given that the official purpose of the U.S. patent system is the promotion of the “useful arts,” do you think algorithms are patentable in this country? Should they be? 3. a. Write down driving directions for going from your school to your home with the precision required by an algorithm. b. Write down a recipe for cooking your favorite dish with the precision required by an algorithm. 4. Design an algorithm for swapping two 3 digit non-zero integers n, m. Besides using arithmetic operations, your algorithm should not use any temporary variable. 5. Design an algorithm for computing gcd(m, n) using Euclid’s algorithm. 6. Prove the equality gcd(m, n) = gcd(n, m mod n) for every pair of positive integers m and n. 7. What does Euclid’s algorithm do for a pair of numbers in which the first number is smaller than the second one? What is the largest number of times this can happen during the algorithm’s execution on such an input? 8. What is the smallest and the largest number of divisions possible in the algorithm for determining a prime number? 9. a. Euclid’s algorithm, as presented in Euclid’s treatise, uses subtractions rather than integer divisions. Write a pseudocode for this version of Euclid’s algorithm. b. Euclid’s game (see [Bog]) starts with two unequal positive numbers on the board. Two players move in turn. On each move, a player has to write on the board a positive number equal to the difference of two numbers already