Midterm Review for CMPS 6610/4610, Fall 2016
Relevant Material:
- All material from 8/30/16 until 10/4/16 (inclusive).
- This includes material covered in the lectures, and homeworks 1 - 4.
- Analyzing Algorithms (Ch. 2.2)
- Best case and worst case runtimes
- Asymptotic Notation (Ch. 3, A)
- О, Ω, Θ, ο
- Prove by definition (find a value for c>0 and n_0 > 0
so that for all n≥n_0 the inequality is satisfied)
- f(n) ∈ O(g(n))
- f(n) ∈ Ω(g(n))
- f(n) ∈ Θ(g(n)) [prove both O and Ω]
- Know how to use the limit theorem.
- Analyze code snippets.
- Know summations: Arithmetic series, geometric series (finite and infinite), Harmonic number.
- Heaps and Binary Search Trees (Ch. 6, 12.1, 12.2, 13.2)
- Binary search tree definition; BST property
- Rotations
- In-order tree traversal
- Heap definition; max-heap property
- Using array implementation, findMin takes O(1) time, and extractMin and decreaseKey take O(log n) time
- Heapsort: Repeatedly extract min in min-heap; O(n log n) time
- Divide & Conquer (2.3, 4.3, 4.4, 4.5, 4.6)
- You can call an algorithm divide-and-conquer only if the size of
subproblems can be written as n/b where b>1
- Mergesort, binary search, recursive squaring
- Find the runtime recurrence for a recursive algorithm given in pseudocode
- Solving Recurrences: Solve a runtime recurrence (i.e., find an upper bound for a recursively defined T(n)):
- Recursion Tree: Find a guess what a (runtime) recurrence could solve to
using recursion trees
- Given T(n) = aT(n/b) + f(n)
- a = #of subproblems = #of children at each node
- n/b = subproblem size
- Height of the tree = log_b (n) [log of n base b]
- Big-Oh Induction
- Prove your guess/claim using big-Oh induction (substitution method): Find conditions on constants c and n_0 in inductive step. (No need to handle base case.)
- Master Theorem
- Compute n^(log_b (a)) and compare with f(n)
- Clearly write which case of the Master theorem applies, and give the values for ε, k, and c:
- For case 1: Give the value of ε>0
- For case 2: Give the value of k≥0
- For case 3: Give the value of ε>0, check the regularity condition and give the value of c<1
- Proof of the master theorem
- Quicksort and Order Statistics (5.2, C.3, 7, 9)
- Randomized Algorithms
- Probability and expectation
- Expected runtime vs. average runtime, best-case runtime, and worst-case runtime
- Quicksort
- Deterministic quicksort:
- Best-case runtime O(n log n) [When each pivot partitions the array into two roughly equal pieces]
- Worst-case runtime: O(n^2) [When the array is already sorted either increasing or decreasing order]
- Randomized quicksort: Expected runtime O(n log n)
- Order Statistics
- Select the i-th smallest element
- Randomized selection: Worst-case runtime O(n^2),
expected runtime O(n)
- Deterministic selection: Select median of medians; worst-case runtime O(n)
- Dynamic Programming (Ch. 15.2-15.4):
- Applies only if the problem has the following two properties:
- Optimal substructure (recursion)
- Overlapping subproblems
- In dynamic programming each subproblem is solved only once, and its solution is stored in a DP table. This stored value/solution will be used later whenever needed.
- LCS, matrix chain multiplication
- (Bottom-up) DP: Use one or more nested loops and fill the whole DP table bottom-up.
Practice Problems from the Book:
- Analyzing algorithms:
- page 22: 2.1-2, 2.1-3
- page 39: 2.3-3,4,5,6,7
- page 39: 2-1,4
- Asymptotic notation:
- page 52: 3.1-1,2,3,4,5
- page 61: 3-1,2,3,4
- Heaps and binary search trees:
- page 153: all exercises
- page 156: 6.2-3, 6.2-4
- page 160: 6.4-3
- page 167: 6-2
- page 289: 12.1-1,2,3,4
- page 314: 13.2-3
- Divide & conquer:
- page 87: all exercises
- page 92: all exercises
- page 96: 4.5-1,2,3
- page 107: 4-1,3
- Quicksort and order statistics:
- page 1200: C.3-1,2,3,4
- page 122: 5.2-3,4,5
- page 143: 5-2
- page 173: all exercises
- page 178: 7.2-1,2,3
- page 219: 9.2-3,4
- Dynamic programming:
- page 389: 15.3-1,2,3,4
- page 396: 15.4-1,2,3,4,5
- page 406: 15-5