Final Review for CMPS 2200, Fall 2017

Relevant Material:

  1. Topics from the Midterm Review
  2. More Divide-and-Conquer and Runtime Recurrences [Ch. 2 Dasgtupa, Ch. 4 CLRS]
    • Recursive algorithms and thinking
      • Strassen's matrix multiplication
    • Master Method
      • Find the value of a and b
      • Compare f(n) with n^(log_b (a))
      • Please clearly write which case it is and give the values for epsilon, k, and c:
        • For case 1: Give the value of epsilon>0
        • For case 2: Give the value of k>=0
        • For case 3: Give the value of epsilon>0, check the regularity condition and give the value of c<1
  3. Dynamic Programming (DP):[Ch. 6 Dasgupta, Ch. 15 CLRS]
    • An algorithm design technique where
      • each subproblem is solved only once and the solution is stored in a dynamic programming table (DP table),
      • and this stored value/solution will be used later whenever needed.
    • This approach applies only if the problem has the following two properties:
      • Optimal substructure (recursion)
      • Overlapping subproblems
    • There are two DP approaches:
      • Bottom-up: Uses one or more nested loops and fills the whole DP table systematically bottom-up.
      • Memoization: Use recursion and fills only the cells of the DP table which are needed during the recursion, in the order determined by the recursion.
    • Sample Questions:
      • Understand a given recursive solution, and analyze the time and space needed for a brute-force implementation of the recursion.
      • Develop a recursive solution for a problem similar to problems covered in class or on the homework.
      • Design a DP algorithm using a given recurrence and bottom-up dynamic programming.
    • Analyze time and space of your DP algorithm.
    • Give an algorithm to fill the DP table for a given recursive solution and compute the solution from it.
  4. Greedy Algorithms[Ch. 6 Dasgupta, Ch. 16 CLRS]
    • Greedy Strategy:
      • Repeatedly identify the decision to be made (recursion)
      • Make a locally optimal choice for each decision
    • Greedy does not always work.
    • Making change, knapsack (greedy algorithms for special variants of the problems, DP algorithms for general problems)
    • Sample Questions:
      • Short questions or true/false about the concepts
      • Come up with a greedy solution to a problem or with a counter-example why a greedy solution does not work
  5. Graphs: [Ch. 3, 4, 5 Dasgupta, Ch. 22, 23, 24 CLRS]
    • Representation of Graphs:
      • Adjacency matrix
      • Adjacency lists
      • Handshaking lemma
      • Sample Questions:
        • Come up with an algorithm to convert given adjacency lists to an adjacency matrix or vice versa.
    • Graph Traversal: Assume the graph G=(V,E) is represented using adjacency lists. Note that the assignment of timestamps depends on the order of vertices in the adjacency lists or matrix. For example, if vertices are alphabetically ordered then if a has b, c and d in its list then b will be visited/discovered first from a, not c or d.
      • Breadth First Search:
        • Runtime: O(|V|+|E|)
      • Depth First Search:
        • Runtime: O(|V|+|E|)
        • DFS edge classification
        • Directed Acyclic Graph (DAG) and topological sort
      • Sample Questions:
        • For a given graph, give discover/finish times using DFS.
        • For a given graph, give visit times using BFS.
        • Runtimes of BFS and DFS when different variants of graph representations (adjacency lists vs. adjacency matrix) are used.
    • Single Source Shortest Paths
      • Dijkstra: Works only for non-negative edge weights.
        • Runtime: Θ(|V|)·T_EXTRACT-MIN + Θ(|E|)·T_DECREASE-KEY
        • Runtimes using different variants of graph representations and priority queues (linked list, min-heap or array)
      • Bellman-Ford: It works for any edge weights and can detect negative weight cycles.
        • Runtime: O(|V||E|)
        • For a DAG, run Topological Sort and then one round of Bellman-Ford. Runtime O(|V|+|E|)
      • Sample Questions:
        • For a given graph, run Dijkstra's/Bellman-Ford algorithm and show all different steps (vertex weights, priority queue, predecessor array).
        • Modify Dijkstra's and Bellman-Ford's algorithm and determine if they are still correct.
    • Minimum Spanning Tree (MST)
      • Prim:
        • Runtime: Θ(|V|)·T_EXTRACT-MIN + Θ(|E|)·T_DECREASE-KEY
        • Runtimes using different variants of graph representations and priority queues (linked list, min-heap or array)
      • Kruskal:
        • Runtime: O(|E|log|E|) which comes from sorting all the edges.
      • Sample Questions:
        • For a given graph run Prim's algorithm and show all different steps (vertex weights, priority queue, predecessor array)
        • For a given graph run Kruskal's algorithm and show the subsets of different steps.
  6. Amortized Analysis [Ch. 17 CLRS]
    • Aggregate analysis, accounting method
    • Dynamic tables, binary counter
  7. Sorting and Order Statistics [Ch. 2 Dasgtupa, Ch. 4 CLRS]
    • Decision Trees:
      • For a given (sorting or searching) algorithm
      • Lower bound for comparison sorting (or searching) algorithms.
    • Counting Sort:
      • Runtime: O(n+k)
    • Radix Sort:
      • Runtime: O(bn/(log n))
    • Randomized Algorithms:
      • Expected runtime vs. average runtime, best-case runtime, and worst-case runtime
      • Expected runtime analysis, using indicator random variables
    • Quicksort
      • Runtime:
        • Best case: O(n log n) [When each pivot partitions the array into two roughly equal pieces]
        • Worst case: O(n^2) [When the array is already sorted either increasing or decresing order]
        • Average case: O(n log n)
        • Expected runtime for randomized quicksort: O(n log n)
    • Order Statistics
      • Randomized Select Algorithm: to select the i-th smallest element
        • Runtime:
          • Worst case: O(n^2)
          • Best case: O(n)
          • Expected Runtime: O(n)
    • Sample Questions:
      • Construct a decision tree for a given sorting or searching algorithm
      • Analyze the runtimes of different sorting algorithms on a specific input array.
  8. P and NP
    • Definition of P, NP, NP-hard, NP-complete
    • Reductions, NP-complete problems (SAT, Clique, TSP, Vertex Cover, Independent Set)
    • Sample Questions:
      • For a given problem, show if it is in NP or not, justify your answer.
      • Definition and basic properties of reductions


Practice problems from the books:

  1. More divide-and-conquer and runtime recurrences:
    • Dasgupta, chapter 2: Exercises 4, 5, 11, 16 (advanced), 23
    • CLRS, page 39: 2.3-3,4,5,6
    • CLRS, page 96: 4.5-1,2,3
    • CLRS, page 107: 4-1,3 (use the master theorem if possible)
  2. Dynamic Programming:
    • Dasgupta, chapter 6: Exercises (advanced) 1 - 9
    • CLRS, page 389: 15.3-2
    • CLRS, page 396: 15.4-1,2,3,4,5
  3. Greedy Algorithms:
    • Dasgupta, chapter 6: Exercises 13(a), 18, 19
    • CLRS page 427: (advanced) 16.2-3,4,5
  4. Graphs:
    • Representation of Graphs, and Graph Traversal:
      • Dasgupta, chapter 3: 1-9, 11-25
      • CLRS, page 592: 22.1-1,2,3,4,5,6
      • CLRS, page 601: 22.2-1,2,3,4,5,9
      • CLRS, page 610: 22.3-2,7,8,11
      • CLRS, page 615: 22.4-1,2,3,5
      • CLRS, page 621: 22-1 (advanced)
    • Minimum Spanning Tree:
      • Dasgupta, chapter 5: 1,2,5,6,9
      • CLRS, page 637: 23.2-2,4,5,8
    • Single Source Shortest Paths:
      • Dasgupta, chapter 4: 1-14, 17
      • CLRS, page 654: 24.1-1,3, 4 (advanced)
      • CLRS, page 662: 24.3-1,2,3
      • CLRS, page 676: 24.5-1,2
  5. Amortized Analysis & Union-Find:
    • Dasgupta, chapter 5: 25
    • CLRS, page 456: 17.1-1,2,3
    • CLRS, page 458: 17.2-1,2,3
  6. Sorting and Order Statistics:
    • Dasgupta, chapter 2: Exercises 18, 20, 22 (advanced)
    • CLRS, page 1200: C.3-1,2,3,4
    • CLRS, page 122: 5.2-3,4,5
    • CLRS, page 173: all exercises
    • CLRS, page 178: 7.2-1,2,3
    • CLRS, page 219: 9.2-4
  7. P and NP
    • Dasgupta, chapter 8: 1, 2, 4, 13