You are on page 1of 1

CMSC-5343 Algorithm Analysis

Homework 1 - 200 pt

Below, you will find the problems assigned for this assignment. Please elec-
tronically submit your assignment to blackboard.

1. Consider sorting n numbers in an array A by finding the smallest element of

A and swapping it with the first element of the array, then sorting the remaining
n 1 elements using the same process. This algorithm is known as selection
sort. Write pseudocode for this algorithm. What loop invariant or invariants
does this algorithm maintain? Give the worst-case runtime in notation.

2. Use mathematical induction to prove the following:

k 2 = n(n+1)(2n+1)
a) 6
b) The solution of the following recurrence:
T (n) = 2 for n = 2 T (n) = 2T (n/2) + n for n = 2k , k > 1
is T (n) = n lg n.

3. Show that for any real constants a and b, (n + a)b = (nb ).

4. Prove or disprove that:

a) 2n+1 = O(2n )
b) 22n = O(2n )

5. Find big- bounds for the following recurrences (assume that adequate base
cases exist for each):
a) T (n) = T (n 1) + n
b) T (n) = T (n/2) + 1
c) T (n) = 4T (n/2) + n2
d) T (n) = T (n 1) + T (n 2)