Вы находитесь на странице: 1из 3

# B.

## E Third Year 2016

Department of Computer Engg., Jamia Millia Islamia, New Delhi-110025
Subject: Design and Analysis of Algorithms
Assignment Marks -25
Q1. Write shorts notes on O, Ө and Ω Asymptotic notations. Give one example of each. And solve the
following :
(i) Prove that running Time T(n)=n3+20n+1 is O(n3)
(ii) Prove that running Time T(n)=n3+20n+1 is not O(n2)
(iii) Prove that running Time T(n)=n3+20n+1 is O(n4)
(iv) Prove that running Time T(n)=n3+20n is Ω(n2)
n
(v) Prove that  log i is Ө(nlogn)
i 1
(vi) Prove that n!=o(n2)
(vii) Prove that running Time T(n)=n3+20n is Ω(n2)
Q2. Find the complexities of following algorithms.
a) Bubble Sort
b) Selection Sort
c) Insertion Sort
d) Early termination Bubble sort
e) Finding the maximum element in n array
Q3. Write Algorithm for
a) Merge Sort
b) Quick Sort
c) Heap Sort
And also give example of each algorithm. (Show each iteration and Use your Own data for e.g.)

Q4. Solve following Recurrence Equation using Iteration method, substitution method, recurrence tree
method and Master’s theorem as marked in table .Assume that T (n) is constant for n ≤ 2.
S.No. Recurrence Equation Master’s Iteration recurrence substitution
theorem method tree method
method
1 T (n) = 2T (n/2) + n Y Y Y Y
3

## 2 T (n) = 2T (n/2) + n2 Y Y Y -----

3 T (n) = 8T (n/2) + n2 Y Y Y Y
4 T (n) = 2T (n/2) + cn Y Y Y Y
5 T (n) = 9T (n/3) + n Y Y Y -----
6 T (n) = T (2n/3) + 1 Y Y Y Y
7 T (n) = 3T (n/4) +nlogn (Ans:Ө(nlogn)) Y ----- ----- -----
8 T (n) = 2T (√n) + lgn Y ----- ----- -----
(Ans: Ө(logn log(logn)) )
9 T (n) = 4T (n/2) + n3 Y Y Y -----

10 T (n) = 4T (∟n/2 ɺ) + n Y Y Y Y

## S.No. Recurrence Equation Master’s Iteration recurrence substitution

By: Shahzad Alam, Dept. of Comp. Engg. Jamia Millia Islamia Page 1
theorem method tree method
method
11 T (n) = 5T (n/2) + n3 Y Y Y -----
12 T (n) = 3T (n/4) + cn2 Y Y Y Y
13 T (n) = T (√n) + Ө(log(logn)) Y ----- ----- -----
14 T (n) = 3T (n1/3)+log3n (Hint Let k= Y ----- ----- -----
log3n)
15 T (n) = 7T (n/2) +O(n2) (Ans: O(n2.808)) Y ----- ----- -----
16 T(n)=T(αn)+T((1-α)n)+n where α is ----- ----- Y -----
constant in the range 0<α<1
17 T(n)=T(n/3)+T(2n/3)+n ----- ----- Y -----
18 T(n)=T(n/2)+T(n/4)+ T(n/8)+n ----- ----- Y -----
19 T (n) = 3T (∟n/4 ɺ) + n Y Y Y Y
20 T (n) = T (n − 1) + n4 ----- Y Y -----
21 T (n) = T (n − 1) + 1 & T(1)=Ө(1) ----- Y Y -----
22 T (n) = T (n − 1) + 1/n ----- Y Y -----
23  1 n 1 ----- Y Y -----
T (n) = 
2T (n  1) n  1
24 T (n) = T (n/3) + n4/3 Y ----- ----- -----
25 T (n) = T (9n/10) + n. Y Y ----- -----
26 T (n) = 16T (n/4) + n2 Y Y Y -----
27 T (n) = 7T (n/2) + n2 Y Y Y Y

## Or T (n) = 7T (n/2) + O(n2)

28 T (n) = 2T (n/4) +√n Y ----- ----- -----
29 T (n) = T (√n) + 1 Y ----- ----- -----
30 T (n) = 2T (n/2) + Ө (n). Y Y Y Y
31 T (n) = 2T (n/2) + nlgn Y Y Y -----
32 T(n)=T(n-a)+T(a)+n where a>=1 is a ----- ----- Y -----
constant
33 T(n)=10T(n/3)+17n1.2 (Ans: Ө(nlog310)) Y ----- ----- -----
34 T(n)=T(n/2) + 2n (Ans:Ө(2n)) Y ----- ----- -----

## Q5. What do you understand by

(i) DFS algorithm (explain with example)
(ii) BFS algorithm (explain with example)
(iii) Greedy Algorithms
(iv) Dynamic Programming

By: Shahzad Alam, Dept. of Comp. Engg. Jamia Millia Islamia Page 2
Q6. Write the recurrence equation of Strassen’s algorithm for multiplying the matrix. Use
Strassen’s algorithm to compute the product to two given square matrix:

1 2 5 7 
3 4 and 6 8
   

Q7. What do you understand by Activity Selection Problem? Given ten activities along with their
start and finish time as
S = A1 , A2 , A3, A4 , A5 , A6 , A7 , A8 , A9 , A10

Si = 1,2,3,4,5,6,7,8,9,10
fi = 5,3,4,6,7,8,11,13,12,10
Compute schedule using greedy approach, where the largest number of activities takes place.

## Q8. Consider 7 items along their respective weights and values

I = I1 , I 2 , I 3 , I 4 , I 5 , I 6 , I 7

W = 2,3,5,7,1,4,1
V = 10,5,15,7,6,18,3
The capacity of knapsack W=15. Find the optimal solution of the fractional knapsack problem.
What is the complexity of finding the solution of fractional knapsack problem?

## Q9. Compute the optimal sequence for the multiplication operation of

(i) A4x2 B2x5 C5x3 D3x4
(ii) A5x3 B3x5 C5x6 D6x3
matrices using dynamic programming.

Q10. What do understand by LCS problem? Find the longest common subsequences of X and Y
where
(i) X= “ABCDBCDC” and Y=” BCDCD”
(ii) X= “POLYNOMIAL” and Y= “ EXPONENTIAL”

Q11. Write the short notes on NP class, NP hard and NP complete problems? Give example of each
problem

Q12. Define Horner’s rule? For string matching working module q = 11, how many spurious hits
does the Rabin-Karp matcher encounter in the text T = 39798535626951413, when looking for the
pattern P = 26?

Q13. Construct the string matching automation for the pattern P=baab and illustrate its operation on
the text string T=bababaabaaabbaab

## LAST DATE 30 SEPTEMBER 2016

By: Shahzad Alam, Dept. of Comp. Engg. Jamia Millia Islamia Page 3

## Нижнее меню

### Получите наши бесплатные приложения

Авторское право © 2021 Scribd Inc.