You are on page 1of 1

Assignment: 7

Q:1 I. II. Answer the following questions (Any Five). What do you mean by analysis of an algorithm? Write down any algorithm whose time complexity is independent of the input. (Its complexity will remain same for each instance of the input). What will be the time complexity of such type of algorithm? Explain the working of Insertion sort. Give a real life example where insertion sort can be applied. Define Big-Oh and Big-Omega notation using set theoretic notation. Write a recurrence relation to solve Tower of Hanoi problem. Solve it to calculate its timecomplexity. Give a real life application/problem where Divide and Conquer strategy can be applied. Also explain how that problem will be solved using Divide and Conquer strategy. Solve the following recurrence: T(n) = 9T(n/3) + n2 When n is power of 3, n>=3. Matrix multiplication using divide and conquer method is more efficient then classic method. Justify you answer. Write down the time complexity of each of the following code. Boolean is_prime(int n) int sum(int a[], int n) while(n>0) { { { if(prime(n)==1) If(n==0) rem=n%10; return true; return 0; sum=sum+rem; else else return n=n/2; return false; (sum(a,n-1)+a[n]); } } } Write an algorithm to insert an element at desired position into an array. What are the worst case, average case and best case for the same? What will be time complexity for each case? OR Total number multiplications required to find exponent will be reduced using divide and conquer strategy over sequential method. Justify your answer. Also give a suitable example to make your justification stronger. Write down an algorithm to explain working of Merge sort. Write a recurrence for the same. Analyze its time complexity. Also give a suitable example to illustrate the merge sort. (Take input of at-least size 8). Write down an algorithm to perform multi-pop operation on the stack. Find out the amortized cost for stack operations using Accounting method. OR Write down the algorithm for recursive binary search and linear search. Compare their timecomplexity. Which one is batter? Also give a suitable example to justify your answer. Write down an algorithm to increment a binary counter. Find out the amortized cost to increment binary counter using Accounting method. ------------------------------

10

III. IV. V. VI. VII.

Q:2

I
II

3 3

III

Q:2

III

Q:3

I
II

I
II

7 3

You might also like