This ?le contains the exercises, hints, and solutions for Chapter 2 of the book Introduction to the Design and analysis of Algorithms, 2nd edition, by A. Levitin. The problems that power be challenging for at least some students argon pronounced by ; those that dexterity be di?cult for a majority of students be pronounced by . Exercises 2.1 1. For each of the following algorithms, indicate (i) a congenital size metric for its inputs; (ii) its basic movement; (iii) whether the basic performance count crowd out be di?erent for inputs of the same size: a. reckoning the sum of n rounds b. computing n! c. ?nding the largest parcel in a diagnose of n numbers d. Euclids algorithm e. sieve of Eratosthenes f. pen-and-pencil algorithm for multiplying two n-digit decimal integers 2. a. pass along the de?nition-based algorithm for adding two n-by-n matrices. What is its basic operation? How many footfall is it performed as a function of the matrix order n? As a function of the total number of elements in the input matrices? b. Answer the same questions for the de?nition-based algorithm for matrix multiplication. 3. buy the farm a variation of sequential search that scans a attend to return the number of occurrences of a given search happen upon out in the list. Will its e?ciency di?er from the e?ciency of unstained sequential search? 4. a.
Glove natural selection on that point are 22 gloves in a drawer: 5 pairs of rosy gloves, 4 pairs of yellow, and 2 pairs of green. You select the gloves in the ominous and can check them only afterward a selection has been made. What is th e smallest number of gloves you need to sele! ct to have at least nonpareil matching pair in the best possibility? in the pommel case? (after [Mos01], #18) b. Missing socks Imagine that after washables 5 distinct pairs of socks, you discover that two socks are missing. Of course, you would resembling to have the largest number of complete pairs remaining. Thus, you are left with 4 complete pairs in the best-case scenario and with 3 complete pairs in the scald case. Assuming that the probability of...If you want to get a ethical essay, order it on our website: OrderCustomPaper.com
If you want to get a full essay, visit our page: write my paper
No comments:
Post a Comment