# Algo exercise

May 8th, 2015
Studypool Tutor
Price: \$10 USD

Tutor description

Analysis and Design of Algorithms

Word Count: 732
Showing Page: 1/6
Algo exerciseAnalysis and Design of Algorithms1. Compute the following sums:a. Answer:= = u 1 + 1 = (n + 1) 3 + 1= n + 1 2= n - 1b. Answer:= = [1 + 2] + + n= + (n + 1) (1 + 2)= + (n + 1) 3= + n 2= n(n + 1) + (n - 2)2= n2 + n + (n - 2)2= n2 + 3n 42c. Answer:= = = n (n+1) (2n + 1) + n (n+1)6 2= (n - 1) (n -1 + 1) (2 ( n 1) +1) + (n - 1) (n 1 + 1) 6 2 = (n - 1) (n) (2n 2 + 1) + (n 1) (n)6 2= (n2 - n) (2n 1) + (n 1) (n)6 2= (n3 - n2 - 2n2 + n) + (n2 n)6 2= 2n3 - 3n2 + n + n2 n6 2 = 2n3 - 3n2 + n + 3n3 3n6 = 2n3 2n6 = n3 n3 = n2 13 2. Consider the following algorithm.Algorithm Mystery( n)//Input: A nonnegative integer nS 0for i 1 to n doS S + i * ireturn Sa. What does this algorithm compute?Answer:S(n) = 2b. What is its basic operation?Answer:Multiplicationc. How many times is the basic operation executed?Answer:At least one timed. What is the efficiency class of this algorithm?Answer:C(n) = n (n)e. Suggest an improvement or a better algorithm altogether and indicate its efficiency class. If you cannot do it, try to prove that, in fact, it cannot be done. Answer:2 = n (n + 1) (2n + 1)63. Consider the following algorithm.Algorithm Secret(A[0..n 1])//Input: An array A[0..n 1] of n real numbersminval A[0]; maxval A[0]for i 1 to n 1 doif A[i] < minvalminval A[i]

## Review from student

Studypool Student
" all I can say is wow very fast work, great work thanks "

1830 tutors are online

### Other Documents

05/08/2015
05/08/2015
05/08/2015
05/08/2015

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors