The purpose of this assignment is to practice your analysis of algorithm complexity. It is recommended that this assignment be printed, and that the work be done right on it. This assignment is to be submitted in paper form to the assignment boxes, just to the left of the elevators, on the second floor of the Goldberg CS Building. For each of the algorithms below:
- Derive the cost function for the algorithm. Be sure to show your work like we do in lectures.
- State the complexity of the algorithm in Big-Oh.
- Prove that the derived cost function is in the stated order (big-Oh).
input: A[n][n] and B[n][n] // 2D arrays of size n x n
input: A[n][n], F // 2D arrays
Based on code from https://en.wikipedia.org/wiki/Longest_common_subsequence_problem
input: X[n], Y[n]
output: length of longest common sequence between X and Y
C = Array[n][n]
for i = 0 ... n
C[i,0] = 0
C[0,i] = 0
for i = 1 ... n
for j = 1 ... n
if X[i] == Y[j]
C[i,j] = C[i-1,j-1] + 1
else if C[i,j-1] < C[i-1,j]
C[i,j] = C[i-1,j]
C[i,j] = C[i,j-1]
input: n-bit integer X // see not below the algorithm
Note: Recall that the range of values of an n-bit integer is 0 … 2^n.
- Print this assignment and show your work right on it.
- Feel free to use O(1) instead of specific constants when analyzing the algorithms.
- Be sure to show your work!
Each problem will be graded out of 10 points:
4 marks for deriving the correct cost function. The cost function should be of the correct order, and it should be clear how it was derived from the algorithm. One mark for the correct answer, three marks for showing your work.
2 marks for identifying the correct order of the function (big Oh). One mark for the correct order, and one mark for correct notation. I.e., no multiplicative constants, or multiple terms.
4 marks for justifying your answer. Follow the steps discussed in lecture. Approximately, 1 mark per step.
Submit you assignment in hardcopy (paper form) to the submission box, which is located to the left of the elevators, on the second floor of the CS Goldberg Building.