Analysis and Design of Algorithms

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

Tutor description

Assignment 3 to Compute the given sums

Word Count: 761
Showing Page: 1/8
Analysis and Design of AlgorithmsTK3043 : Analysis and Design of AlgorithmsAssignment 31. Compute the following sums:a. ?Answer:=?=u-1+1= (n + 1) - 3 + 1=n+1-2=n-2b. ?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)62= (n - 1) (n -1 + 1) (2 ( n -1) +1) + (n - 1) (n - 1 + 1) 62= (n - 1) (n) (2n - 2 + 1) + (n - 1) (n)622= (n - n) (2n - 1) + (n - 1) (n)62= (n3 - n2 - 2n2 + n) + (n2 - n)62= 2n3 - 3n2 + n + n2 - n62= 2n3 - 3n2 + n + 3n3 - 3n6= 2n3 - 2n6= n3 - n32=n -132. 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:2S(n) = ?b. 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]if A[i] > maxvalmaxval ? A[i]return maxval ? minval

Review from student

Studypool Student
" The best tutor out there!!!! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1819 tutors are online

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