ADA Assignment 1 Unit 1
ADA Assignment 1 Unit 1
Instructions:
1. A new game in the App store called AmazeMe involves finding a path out of an n- CO1
dimensional maze. The authors of the game claim there is a solution with worst case
complexity O(n4 log n). where n is the number of dimensions.
From this, we can conclude that:
a. For every sufficiently large n, every input maze of dimension n requires time
proportional to n4 log n.
b. For every sufficiently large n, every input maze of dimension n can be solved
within time proportional to n4 log n.
c. For every sufficiently large n, there is an input maze of size n that requires
time proportional to n4 log n.
d. For some n, every input maze of size n requires time proportional to n4 log n.
2. We have 8 sorted lists, each of length n. We need to merge them into a single sorted CO1
list. We merge them in pairs to get 4 sorted lists of length 2n, then 2 sorted lists of
length 4n and finally 1 sorted list of length 8n. What is the complexity of this
procedure?
What is step count method? Compute the complexity of the following algorithm
using step count
2. {
3. int sum = 0;
4. for (int i = 0; i < n; i++)
5. sum += a[i];
6. return sum;
7. }
3 Compute the complexity of the following algorithm using step count CO1
if i < j then
end if;
4 Explain different methods to solve recurrences relation
5. For each of the following recurrences, give an expression for the runtime T (n) if the CO2
recurrence can be solved with the Master Theorem. Otherwise, indicate that the
Master Theorem does not apply.
Solve
6 What is insertion sort? Sort the following numbers in increasing order using insertion CO1
sort 5 2 4 6 1 3.
Analyze the time complexity for best case, average case and worst case.
T(n) = 2T(n/2) + n
9. Solve the following questions using Master Theorem: CO1
1. T (n) = 3T (n/2) + n2
2. T (n) = 4T (n/2) + n2
3. T (n) = T (n/2) + 2n
10. Write an algorithm to find the maximum element in an array of n elements. Give the CO2