Professional Documents
Culture Documents
Assignment 1: ALGORITHM Mystery (N)
Assignment 1: ALGORITHM Mystery (N)
1. Do a self-study on Space Complexity of algorithms and, write an essay on what you have
understood about the same, giving ample examples.
2. Refer to the topic 2.3 in the textbook by Anany Levitin for reference and calculate the time
complexities of the following non-recursive algorithms:
a. Element uniqueness check whether all the elements in a given array of n elements are
distinct.
b. Matrix multiplication
c. Number of binary digits in the binary representation of a positive decimal integer.
d. Sequential Search.
4. Refer to the topic 2.4 in the textbook by Anany Levitin for reference. Arrive at a recurrence
relation with an appropriate initial condition and solve the recurrence or, at least, ascertain the
order of growth of its solution of the following recursive algorithms:
a. Tower of Hanoi
b. Recursive version of the problem mentioned in the question 2.c above.
c. Fibonacci numbers
5. Consider the following recursive algorithm for computing the sum of the first n cubes: S(n) = 13 +
23 + . . . + n3:
ALGORITHM S(n)
//Input: A positive integer n
//Output: The sum of the first n cubes
if n = 1 return 1
else return S(n 1) + n n n
a. Set up and solve a recurrence relation for the number of times the algorithms basic
operation is executed.
b. How does this algorithm compare with the straightforward non-recursive algorithm for
computing this sum?