This ?le contains the exercises, hints, and solutions for Chapter 2 of the book Introduction to the Design and psychoanalysis of Algorithms, 2nd edition, by A. Levitin. The problems that power be challenging for at least some students argon pronounced by ; those that magnate be di?cult for a majority of students are tag by . Exercises 2.1 1. For each of the following algorithms, indicate (i) a inhering size of it metric for its inputs; (ii) its basic movement; (iii) whether the basic subprogram 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 break open 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. pack the de?nition-based algorithm for adding two n-by-n matrices. What is its basic operation? How many appreciate 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. fall out a variation of sequential search that scans a add up to return the number of occurrences of a given search paint out in the list. Will its e?ciency di?er from the e?ciency of unstained sequential search? 4. a.

Glove plectron in that location 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 unforgiving and can check them only later on a selection has been made. What is the smallest number of gloves you need to select to have ! at least nonpareil matching pair in the best model? 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 flog case. Assuming that the probability of...If you want to get a square essay, order it on our website:
OrderCustomPaper.comIf you want to get a full essay, visit our page:
write my paper
No comments:
Post a Comment