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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
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 dicult 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 ocial 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 Euclids algorithm. b. Estimate how many times faster it will be to find gcd (31415, 14142) by Euclids 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 Euclids 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 algorithms execution on such an input? 8. a. What is the smallest number of divisions made by Euclids algorithm among all inputs 1 m,n 10? b. What is the largest number of divisions made by Euclids algorithm among all inputs 1 m,n 10? 9. a. Euclids algorithm, as presented in Euclids treatise, uses subtractions rather than integer divisions. Write a pseudocode for this version of Euclids algorithm. 1 b. Euclids 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 Euclids 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

This note was uploaded on 04/28/2010 for the course CS CSE taught by Professor Drt during the Spring '10 term at Kaplan University.

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 Right Arrow Icon
Ask a homework question - tutors are online