Indian Institute of Technology Ropar
Department of Mathematics
MA514 – Design and Analysis of Algorithms
Tutorial Sheet – 1
1. Prove that if f = O(g), then f ∈
/ ω(g).
P
2. Let f (n) = ni=1 log i and g(n) = n log n. Determine whether f = O(g), f = Ω(g),
or f = Θ(g).
3. Arrange the following functions in order of increasing growth rate, with g(n) following f (n) in your list if and wif f (n) = o(g(n)).
(a) (log n)5
(b) n0.99
(c) n log log n
(d) n
(e) (log n)!
√
(f) 2 log n
(g) n!
4. Find the asymptotically tight time complexity of each of the following recurrence
relations.
(a) T (n) = 2T (n/2) + 1
(b) T (n) = T (n/3) + T (2n/3) + cn, where c > 0
√
(c) T (n) = 2T (n/2) + n
(d) T (n) = T (⌊n/3⌋) + T (⌈2n/3⌉) + n
5. An array of n distinct integers first increases strictly and then decreases strictly.
Design an efficient algorithm to find the maximum element. Analyze the worst-case
running time of your algorithm.
6. A sorted array A[1 . . . n] contains distinct integers. Design an efficient algorithm to
determine whether there exists an index i such that A[i] = i. Justify the correctness
of your algorithm and analyze its worst-case running time.
7. An array of n distinct integers is sorted except that exactly one element is misplaced.
Design the most efficient algorithm to determine whether a given key x is present
in the array. Justify your algorithm and analyze its worst-case running time.
8. Given a sorted array A of n distinct integers and an integer x, determines whether
there exist two elements in A whose sum is exactly x.
9. You are given an n × n matrix where every row and column is sorted in increasing
order. Write an efficient algorithm to search for an element in this matrix. Analyze
its time complexity.
1