|
|
|
|
|
|
|
|
Introduction to Algorithms : Problem Set 1 |
|
|
|
|
|
|
|
|
|
|
- Given an array of n integers, write an algorithm to find the smallest element. Find number of instruction executed by your algorithm. What are the time and space complexities?
- Write a algorithm to find the median of n numbers. Find number of instruction executed by your algorithm. What are the time and space complexities?
- Write a C program for the problem 1.
- Write a C program for the problem 2.
- Solve the following recurrence relations. Assume T(1) = O(1)
|
|
|
|
- T(n) = T(n-2) + cn
- T(n ) = 2T(n/2) + c n^2
- T(n) = 2T(n/2) + c n^3
- T(n) = 4 T(n/4) + O(n)
- T(n) = 4 T(n/2) + c n
- T(n) = T(n/2) + O(1)
- T(n) = 2T(n/2) + n log n
- T(n) = T(n-1) + 1/n
- T(n) = T(n/2) + log n
- T(n) = T(
) + 1
|
|
|
|
|
|
|
|
|
|
|
|
Prev |
|
|