1.
a. The efficiency analysis framework concentrates on the order of growth of an algorithm's basic operation count as the principal indicator of the algorithm's efficiency. To compare and rank such orders of growth, computer scientists use three notations. Define these three notations and give their mathematical and graphical representations. (10 points)
b. What is the General Plan for Analyzing the Time Efficiency of Non-recursive and Recursive Algorithms? Where do the two plans differ? (7.5 points)
2.
a. An algorithm is required to have an unambiguous set of instructions and specify a valid set of inputs. Show how Euclid's Algorithm for finding the Greatest Common Divisor of two numbers possesses this requirement. Show the working of the algorithm using 30 and 12 as inputs. (12.5 points)
b. Consider the Middle-School Procedure for computing greatest common divisor. Why is the algorithm in its traditional form not qualified as a legitimate algorithm? (5 points)
3.
a. Write down and discuss the Algorithm Sieve of Eratosthenes. Show the working of the algorithm on n = 20. (9.5 points)
b. For each of the following algorithms, indicate (i) a natural size metric for its inputs, (ii) its basic operation, and (iii) whether the basic operation count can be different for inputs of the same size:
I. computing the average of n numbers (2 points)
II. computing n/n! (2 points)
III. finding the smallest element in a list of n numbers (2 points)
IV. reverse a list of n numbers (2 points)
4.
a. Design an algorithm to find the sorted list from two sorted lists of numbers. For example, for the lists 2, 5, 7, 12, 13, 24 and 1, 6, 15, 17, 35, the output should be 1, 2, 5, 6, 7, 12, 13, 15, 17, 24, 35. What is the maximum number of comparisons your algorithm makes if the lengths of the two given lists are m and n, respectively? (9 points)
b. Assuming that an algorithm running time T(n) is defined by the function of n, i.e. (where n is the metric indicating an input size), prove that the algorithm will run 729 times longer when the input size is increased by three folds. (8.5 points)
5.
a. One of the ways to appreciate the qualitative difference among the orders of growth of the functions is to consider how they react to the increase in their input size. Show that the logarithmic, linear and linearithmic functions increase by 1 unit, twofold and a little bit more than twofold respectively when the input size n is increased by twofold. (7.5 points)
b. The following algorithm searches for a given key k in a given array A. Discuss how the running time of this algorithm can be quite different for the same list of size n. (10 points)
ALGORITHM SequentialSearch(A[0..n−1], K)
// Searches for a given value in a given array by sequential search
// Input: An array A[0..n−1] and a search key K
// Output: The index of the first element in A that matches K
// or −1 if there are no matching elements
i ← 0
while i < n and A[i] ≠ K do
i ← i + 1
if i < n return i
else return −1
6.
a. A section of an algorithm would have the following nested loops performing three different summations as its basic operation. Express them in mathematical summation form and simplify the resultant expression. State the order at which the algorithm runs. (9.5 points)
for i = 0 to n
for j = i + 1 to n−1
for k = j + 1 to n−2
b. Write down the expression that would be generated by the following recursive function for n = 10. (8 points)
function sum(n) {
if (n > 0) {
return n + sum(n−1)
} else {
return 0
}
}

