Thisfile contains the exercises, hints, and solutions for Chapter 1 of thebook ”Introduction to the Design and Analysis of Algorithms,” 3rd edition, byA. Levitin.The problems that might be challenging for at least some studentsare marked byB;those that might be difficult for a majority of students aremarked byIExercises 1.11. Do some research on al-Khorezmi (also al-Khwarizmi), the man fromwhose name the word “algorithm” is derived.In particular, you shouldlearn what the origins of the words “algorithm” and “algebra” have incommon.2. Given that the official purpose of the U.S. patent system is the promo-tion of the “useful arts,” do you think algorithms are patentable in thiscountry?Should they be?3. a. Write down driving directions for going from your school to your homewith the precision required from an algorithm’s description.b. Write down a recipe for cooking your favorite dish with the precisionrequired by an algorithm.4. Design an algorithm for computingb√cfor any positive integer.Be-sides assignment and comparison, your algorithm may only use the fourbasic arithmetical operations.5. Design an algorithm tofind all the common elements in two sorted listsof numbers.For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, theoutput should be 2, 5, 5. What is the maximum number of comparisonsyour algorithm makes if the lengths of the two given lists areandrespectively?6. a. Findgcd(31415, 14142) by applying Euclid’s algorithm.b.Estimate how many times faster it will be tofindgcd(31415, 14142)by Euclid’s algorithm compared with the algorithm based on checkingconsecutive integers frommin{ }down togcd( )7.BProve the equalitygcd( )=gcd( mod)for every pair of positiveintegersand.8. What does Euclid’s algorithm do for a pair of integers in which thefirstis smaller than the second? What is the maximum number of times thiscan happen during the algorithm’s execution on such an input?9. a. What is the minimum number of divisions made by Euclid’s algorithmamong all inputs1≤ ≤10?1Preview Mode
This document has 499 pages. Sign in to access the full document!
