You are on page 1of 2

Lab Assignment 1

Due Date: 15th February, 2017


Total Marks 25 (Weightage is 5% out of 100)
Concepts:
Introduction to Algorithms, Randomized Algorithms, Asymptotic notations, Solving
Recurrences
Instructions:
1. Review notes of the Chapter.
2. Assignment submitted after due date will not be evaluated and a score of
zero will be awarded for this assignment. Submission has to be via
Blackboard.
3. Upload a pdf version of the document.
4. To be completed individually, you may discuss but follow academic honesty
while completing and submitting the assignment.
_____________________________________________________________________________________
Questions:
1. Solve the following recurrences using Masters method: [5
marks]
a. T[n]=4T[n/2] + n2
b. T[n]=2T[n/2]+c
c. T[n] = T[n/2]+T[n/4]+n2
d. T[n] = 2T[n/4] + log n
e. T[n] =2T[n/4] + n!

2. Solve the following recurrences using Recursion tree method: [5


marks]
a. T[n] = T[n/3] + 2T[n/4]+n
b. T[n] = T[n-5]+ 1/n
c. T[n]=T[ n ] + 1
d. T[n] = 2T[n/2]+n/log n
e. T[n]=T[n-1]+T[n/2]+n

3. Give an algorithm to solve the following problem: Given n, a positive integer,


determine whether n is the sum of all its divisors. Analyze the asymptotic
runtime complexity of this algorithm. Write the code in C and plot the
observations. [5 marks]

4. Consider the nave Monte Carlo algorithm for Primality testing presented in
textbook, where Power(x, y) = xy. What should be the value of t for the
algorithms output to be correct with high probability? Write the code in C and
analyze the observations. [5 marks]
n
5. Show that the complexity for T[n] = T[ 2 + 21] + n) is (nlogn).

[5 marks]

You might also like