This ﬁle contains the exercises, suggestions, and solutions for Part 1 of the publication ”Introduction for the Design and Analysis of Algorithms, ” 2nd release, by A. Levitin. The problems that could be challenging for at least some college students are proclaimed by; the ones that might be diﬃcult for a most of students happen to be marked by.

Exercises 1 . 1

1 . Do some research on al-Khorezmi (also al-Khwarizmi), the man coming from whose term the word " algorithm” has been derived from. In particular, you should learn the actual origins from the words " algorithm” and " algebra” have in common. 2 . Given that the ofﬁcial aim of the U. S. patent system is the promotion from the " beneficial arts, ” do you think algorithms are patentable in this region? Should they become? 3. a. Write down driving directions to get going from your school to your house with the accuracy required by an algorithm. w. Write down a recipe to get cooking your favorite dish with the precision required by an algorithm. four. Design developed for changing two 3 digit non-zero integers d, m. Besides using math operations, the algorithm must not use virtually any temporary adjustable. 5. Style an algorithm intended for computing gcd(m, n) employing Euclid's algorithm. 6. Demonstrate the equal rights gcd(m, n) = gcd(n, m mod n) for each pair of confident integers m and in. 7. What does Euclid's formula do to get a pair of amounts in which the ﬁrst number can be smaller than the second one? Precisely what is the largest number of times this may happen throughout the algorithm's performance on this input? almost eight. What is the tiniest and the major number of divisions possible in the algorithm for determining a prime number? on the lookout for. a. Euclid's algorithm, because presented in Euclid's treatise, uses subtractions rather than integer divisions. Write a pseudocode just for this version of Euclid's criteria. b. Euclid's game (see [Bog]) starts with two unequal positive quantities on the table. Two players move in change. On each maneuver, a player must write for the board a good number equal to the difference of two figures already on the board; this number must be new, i. e., unlike all the numbers already within the board. The player who cannot move loses the game. If you choose to move ﬁrst or second in this game? 10. The extended Euclid's algorithm establishes not only the highest common divisor d of two confident integers meters and d but also integers (not necessarily positive) x and y, such that mx & ny = d.

one particular

a. Research a description from the extended Euclid's algorithm (see, e. g., [KnuI], p. 13) and implement it in the language which you have chosen. b. Modify your plan for ﬁnding integer methods to the Diophantine equation ax + by simply = c with any kind of set of integer coefﬁcients a, b, and c. 11. Locker gates There are in lockers in a hallway, designated sequentially via 1 to n. Initially all the locker doors happen to be closed. You make n goes by by the lockers, each time beginning with locker #1. On the ith pass, i = one particular, 2,..., d, you toggle the door of each ith locker: if the door is shut, you open it up; if it is wide open, you close it. For example , after the ﬁrst pass every door is open; on the second complete you only toggle the even-numbered lockers (#2, #4,... ) so that after the second move the even doors are closed and the odd kinds are wide open; the third period through, you close the doorway of locker #3 (opened from the ﬁrst pass), open the door of locker #6 (closed through the second pass), and so on. Following your last move, which locker room doors happen to be open and which are closed? How most of them are open?

2

Tips to Picked Exercises 1 ) 1

1 . It is probably faster to accomplish this by searching the Web, but your library are able to help, as well. 2 . You can ﬁnd disputes supporting either view. There exists a well-established rule pertinent to the matter, even though: scientiﬁc details or mathematical expressions are not patentable. (Why do you think this is the case? ) Nevertheless should this preclude granting patents for a lot of algorithms? several. You may imagine you happen to be writing the algorithms for any human...