Docstoc

Analysis of Algorithm

Document Sample
Analysis of Algorithm Powered By Docstoc
					                        Analysis of Algorithms (CS-365)
                                   Instructor: Toqeer Ehsan

                                      Assignment # 2
Q#1: Fibonacci Series:

By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent number is the
sum of the previous two. Such that:

                      0,1,1,2,3,5,8,13,21,34,55,89,144,……

   a. Design an algorithm to generate Fibonacci Series in the recursive way.
   b. Extract the recurrence relation from the algorithm and solve it using any method to get
      the complexity function.
   c. Provide the bounds on the complexity function.

Q#2: Solving Recurrences:

Using Substitution method:

   a. Show that the solution of T(n) = T(n-1) + n is O(n2)
   b. Show that the solution of T(n) = 2T(n/2+17) + n is O(nlgn)

Use Recursion-Tree method to solve the following Recurrence Relations.

   a. T(n) = 4T(n/2+2) + n
   b. T(n) = 2T(n-1) + n
   c. T(n) = T(n-1) + T(n/2) + n

Use Master Theorem to Give tight bounds to the following Recurrence Relations.

   a.   T(n) = 2T(n/4) + 1
   b.   T(n) = 2T(n/4) + √n
   c.   T(n) = 2T(n/4) + n
   d.   T(n) = 2T(n/4) + n2
   e.   T(n) = 2T(n/3) + nlgn
   f.   T(n) = 3T(n/5) + lg2n
   g.   T(n) = T(n/2) + 2n



Submission Date: BSCS 6th (19-04-2012) , MSc.CS 4th (20-04-2012). Late assignments not
accepted. Coping and cheating will get zero marks.

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:53
posted:4/22/2012
language:English
pages:1
Description: in this document questions are given for the practice of Analysis of Algorithm subject taught in Computer science degree