{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# solu1 - This file contains the exercises hints and...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: This file contains the exercises, hints, and solutions for Chapter 1 of the book ”Introduction to the Design and Analysis of Algorithms,” 2nd edition, by A. Levitin. The problems that might be challenging for at least some students are marked by ; those that might be diﬃcult for a majority of students are marked by . 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 oﬃcial purpose of the U.S. patent system is the promo- tion 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 computing √ n for any positive integer n . Be- sides assignment and comparison, your algorithm may only use the four basic arithmetical operations. 5. a. Find gcd (31415, 14142) by applying Euclid’s algorithm. b. Estimate how many times faster it will be to find gcd (31415, 14142) by Euclid’s algorithm compared with the algorithm based on checking consecutive integers from min { m,n } down to gcd( m,n ) . 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. a. What is the smallest number of divisions made by Euclid’s algorithm among all inputs 1 ≤ m,n ≤ 10? b. What is the largest number of divisions made by Euclid’s algorithm among all inputs 1 ≤ m,n ≤ 10? 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. 1 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 on the board; this number must be new, i.e., different from all the numbers already on the board. The player who cannot move loses the game. Should you choose to move first or second in this game? 10. The extended Euclid’s algorithm determines not only the greatest common divisor d of two positive integers m and n but also integers (not necessarily positive) x and y , such that mx + ny = d....
View Full Document

{[ snackBarMessage ]}

### Page1 / 27

solu1 - This file contains the exercises hints and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online