- | Page
CS6515 - ALGORITHMS- EXAM 1 |
QUESTIONS AND VERIFIED
ANSWERS | LATEST UPDATE |
GRADED A+
Question : Steps to solve a Dynamic Programming
Problem
CORRECT ANSWER : 1. Define the Input and Output.
Define entries in table, i.e. T(i) or T(i, j) is...
Define a Recurrence relationship - Based on a
subproblem to the main problem. (hint: use a prefix of the
original input 1 < i < n).
Define the Pseudocode.
Define the Runtime of the algorithm. Use Time Function notation here => T(n) = T(n/2) + 1...
- | Page
Question : DP: Types of Subproblems (4)
CORRECT ANSWER : Input = x1, x2, ..., xn
Subproblem = x1, x2, ..., xi ; O(n)
Subproblem = xi, xi+1, ..., xj ; O(n^2)
Input = x1, x2, ..., xn; y1, y2, ..., ym
Subproblem = x1, x2, ..., xi; y1, y2, ..., yj ; O(mn)
Input = Rooted Binary Tree
Subproblem = Smaller rooted binary tree inside the Input.
Question : DC: Geometric Series
CORRECT ANSWER : Given r = common ratio and a =
first term in series => a + ar + ar^2 + ar^3 + ... + ar^(n-1)
- | Page
=> a * [(1 - r^n) / (1-r)]
Question : DC: Arithmetic Series
CORRECT ANSWER : Given d = common difference
and a = first term in series => a + (a + d) + (a + 2d) + ... + (a + (n-1)d
Sum = n/2 [2a + (n-1)d]
Question : DC: Solving Recurrences - Master Theorem
CORRECT ANSWER : If T(n) = aT([n/b]) + O(n^d) for
constants a>0, b>1, d>=0:
T(n) = { O(n^d) if d > logb(a) O((n^d)logn) if d = logb(a) O(n^(logb(a))) if d < logb(a) }
- | Page
Question : Nth roots of Unity
CORRECT ANSWER : (1, 2PIj/n) for j = 0, 1, ..., n-1
*Around the Unit Circle!
Question : Steps to solve for FFT
CORRECT ANSWER : 1) Write out Matrix Coefficient
Form based on n (size of input) Mn(w) = [ 1 1 ... 1
- w ... w^n-1
- w^n-1 ... w^((n-1)*(n-1)) ]
...
Find value for w = e^(2PIi)/n, Substitute in Mn(w).
For the input coefficients into nx1 matrix. I.E. [4 0 1 1], let known as B.