Preview

Solu2

Good Essays
Open Document
Open Document
11506 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Solu2
This file 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 might be challenging for at least some students are marked by ; those that might be difficult for a majority of students are marked by .

Exercises 2.1
1. For each of the following algorithms, indicate (i) a natural size metric for its inputs; (ii) its basic operation; (iii) whether the basic operation count can be different for inputs of the same size:
a. computing the sum of n numbers
b. computing n!
c. finding the largest element in a list of n numbers
d. Euclid’s algorithm
e. sieve of Eratosthenes
f. pen-and-pencil algorithm for multiplying two n-digit decimal integers
2. a. Consider the definition-based algorithm for adding two n-by-n matrices. What is its basic operation? How many times 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 definition-based algorithm for matrix multiplication. 3. Consider a variation of sequential search that scans a list to return the number of occurrences of a given search key in the list. Will its efficiency differ from the efficiency of classic sequential search?
4. a. Glove selection There are 22 gloves in a drawer: 5 pairs of red gloves,
4 pairs of yellow, and 2 pairs of green. You select the gloves in the dark and can check them only after a selection has been made. What is the smallest number of gloves you need to select to have at least one matching pair in the best case? in the worst case? (after [Mos01], #18)
b. Missing socks Imagine that after washing 5 distinct pairs of socks, you discover that two socks are missing. Of course, you would like 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 worst case. Assuming that the probability of

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Unit 2 D2

    • 306 Words
    • 2 Pages

    One disadvantage of Ratios is tools of quantitative analysis, which ignore qualitative points of view. For example the stock turn over ration and Asset turnover only look at the quantity and not if the quality of the product is up to standard.…

    • 306 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Biology Quiz Paper

    • 1178 Words
    • 5 Pages

    | | | Student Response | Value | Correct…

    • 1178 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    will help teachers and students to understand, as fully as possible, the markers’ expectations of…

    • 2875 Words
    • 12 Pages
    Good Essays
  • Good Essays

    Soc315

    • 1406 Words
    • 6 Pages

    |White |The United States Census Bureau defines White|The Census database shows the in 2000 out|They practice Christianity or catholicity |They have a real well organize |…

    • 1406 Words
    • 6 Pages
    Good Essays
  • Good Essays

    a) What are the values produced by the following Matlab expressions: i) x = -1e+200; ans1 = log(exp(x)) ii) v = [-1:1] ans2 = v./v.^(1/2) iii) x = 200; h = 1e-14; ans3 = x + h > x b) The computational complexity of some common operations with n by n matrices are Operation Matrix multiplication LU factorization Cholesky factorization Back/forward substitution Tridiagonal solve Flops 2n3…

    • 10483 Words
    • 42 Pages
    Good Essays
  • Good Essays

    Lab2

    • 520 Words
    • 3 Pages

    On your own and without assistance, complete this Lab 2 Answer Form electronically and submit it via the Assignments Folder by the date listed on your Course Schedule (under Syllabus).…

    • 520 Words
    • 3 Pages
    Good Essays
  • Better Essays

    Forum 2 Linear Equations 2

    • 1133 Words
    • 4 Pages

    police officers. There are 38 legs in all. How many of each type of recruit are there?…

    • 1133 Words
    • 4 Pages
    Better Essays
  • Good Essays

    The number of marks is given in brackets [ ] at the end of each question or part…

    • 1445 Words
    • 18 Pages
    Good Essays
  • Satisfactory Essays

    The number of marks is given in brackets [ ] at the end of each question or part…

    • 2101 Words
    • 19 Pages
    Satisfactory Essays
  • Good Essays

    unit302

    • 1236 Words
    • 4 Pages

    Engage in personal development in health, social care or children’s and young people’s setting (SHC 32)…

    • 1236 Words
    • 4 Pages
    Good Essays
  • Better Essays

    The number of marks is given in brackets [ ] at the end of each question or part…

    • 2166 Words
    • 9 Pages
    Better Essays
  • Better Essays

    Chap1 Solman

    • 16496 Words
    • 66 Pages

    7. Although depreciation is always a period cost in a merchandising firm, it can be a product cost in a manufacturing firm.…

    • 16496 Words
    • 66 Pages
    Better Essays
  • Good Essays

    432 Objectives Wk 11 2002

    • 728 Words
    • 4 Pages

    (1) Evaluate Avon’s investment and financing decisions in the late 1980’s. Why was Avon restructuring its business in 1988? Did the changes make sense?…

    • 728 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    |usually be set by the head teacher in collaboration with parents, staff and the community, and will state what the | | | |…

    • 325 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    aiu 2db

    • 312 Words
    • 2 Pages

    Write your response to this element here. My response for this question is that the characteristics are almost the same in there meanings. With romantic and courtly love they can be expressed the same way by thru song or poems by both woman and men. The feelings and thoughts and emotions can be expressed and felt the same way by both parties. The big difference in them is that men are the ones who show more respect and honor to the woman they are perusing. They do this by giving gifts and doing deeds of honor to show how he feels towards the one he is perusing.…

    • 312 Words
    • 2 Pages
    Satisfactory Essays