CS483 - Russell Final Exam Preparation Guide Spring 2023 CS483 Final Exam Topics List Problems [things we are trying to solve/discover…] Graph Problems Optimal Substructure Problems Data Compression Sorting Hard Problems analyzing of and matching in bipartite graphs independent sets in graphs traversing a graph cycle detection in a graph topological sorting of a directed graph paths and shortest paths spanning trees and minimum spanning trees connected components of a graph flows and max flow in flow graphs cuts and min cuts of flow graphs (inc. capacity and net flow across a cut) finding negative cycles [book] disjoint paths [book] flows/circulations [book – optional, but in lecture] with demands with demands and lower bounds with circulations and source/sink [lecture only] activity/interval selection (and variations) optimal caching [book] knapsack [0-1, fractional] kth Fibonacci number [lecture] egg drops longest common subsequence segmented least squares [book] subset sum [book] RNA secondary structure [book] sequence alignment [book] … also some of the graph problems … also data compression problems concept of and goals of data compression prefix codes comparison vs. non-comparison sorts lower bound time complexity on comparison sorts general terms (reducibility, decidable/undecidable, tractable/intractable, optimization vs. decision problems, P/NP/NP-Complete/NP-Hard) Independent Set Vertex Cover SAT and 3SAT Circuit SAT [book] Set Packing [book] CS483 - Russell Final Exam Preparation Guide Other Problems Spring 2023 Travelling Salesman Problem Hamiltonian Cycle Problem Hamiltonian Path Problem [book] 3D Matching Problem [book] Graph Coloring and 3-Color Subset Sum [book] Scheduling with Release Times and Deadlines [book] Halting Problem [lecture] Euler Tour [lecture] competitive facility locations counting inversions [book – ch5] closest pair of points [book – ch5] integer multiplication [book – ch5] convolutions for the Fast Fourier Transform [book – ch5] image segmentation [book – ch 7 + lecture] survey design [book – ch 7 optional] project selection [book – ch 7 optional] baseball elimination [book – ch 7 optional] median finding [book – ch 13] 2-3 from this list for randomized algorithms [ch 13]: Contention Resolution Finding the Global Min Cut Hashing Random Caching Load Balancing Packet Routing Techniques [ways to solve problems we have…] Review: Formal Proofs Algorithm Analysis Basics Amortized Analysis Approaches for Optimal Substructure Problems Divide and Conquer basic formal proofs for algorithms (by contradiction, induction, etc.) empirical vs. mathematical vs. approximation analysis asymptotic notation methods/approaches (aggregate, accounting, potential) [lecture] greedy (including requirements on subproblems, and greedy choice property) dynamic programming (including elements of DP) memoization basic approach and methods analysis using recurrences using: substitution recursion trees master method [lecture] CS483 - Russell Final Exam Preparation Guide Randomized Algorithms Techniques for Harder Problems Spring 2023 indicator random variables probabilistic analysis Reductions (general idea of) Proving equivalence Proving special case of a more general problem Proofs using gadgets Data Structures (with Their Analysis!!!) [for support…] Review: Dynamic Array Lists Review: Stacks and Queues Review: Tree Data Structures Review: Priority Queues w/ Heaps Review: Sets and Maps Review: Graph Data Structures Disjoint Set Data Structures expansion [lecture – amortized analysis] building queues using only stacks [lecture – amortized analysis] stacks with occasional backups [book] tree basic terminology / properties [homework] tree storage [homework] basic operations: add (enqueue) basic operations: remove (dequeue) concept of sets and maps graph basic terminology / properties (e.g. vertices, edges, weights, directed, connected, cycles, paths, degrees, etc.) [book] graph storage (adjacency matrix, adjacency list, edge list, map-of-maps, map-of-sets) and add/remove and vertex/edge operations for each concept of union-able disjoint sets disjoint sets with union find [lecture version] basic operations: find [w/ path-comp] basic operations: union [by-rank-size] use in Kruskal’s MST algorithm Algorithms (with Their Analysis!!!) [to solve problems…] Greedy activity/interval selection algorithms for: scheduling a single resource scheduling all intervals (w/ fewest resources) [book] scheduling with minimum lateness [book] fractional knapsack greedy algorithm [lecture] Huffman coding: creating an encoding tree encoding and decoding messages CS483 - Russell Final Exam Preparation Guide Dynamic Programming Memoization Comparison Sorts Non-Comparison Sorts Review: Graph Basics Graph Algorithms using Basic Walks More Graph Algorithms Spring 2023 kth Fibonacci number DP algorithm [lecture + HW] egg drop DP algorithm [lecture] 0-1 knapsack DP algorithm longest common subsequence DP algorithm segmented least squares [book] subset sum [book] RNA secondary structure [book] sequence alignment [book] kth Fibonacci number MEMO algorithm [HW] insertion sort [lecture] merge sort quick sort (inc. randomized algorithm analysis) counting sort [lecture] radix sort [lecture] bucket sort [lecture] walks: breadth-first walks: depth-first [and edge types created] path detection cycle detection topological sort D-F method [lecture + homework] Kahn’s method [book + homework] shortest paths in unweighted graphs connected components finding connected components [book] strongly connected components [book + homework] bipartite graphs: testing bipartiteness [book] shortest paths in weighted graphs Dijkstra’s algorithm Bellman-Ford algorithm -- and when to use which one! minimum spanning trees Prim’s algorithm [book] Kruskal’s algorithm all-pairs shortest path BFS for unweighted (run repeatedly) Dijkstra’s SP algorithm (run repeatedly) Floyd-Warshall algorithm -- and when to use which one! max-flow and min-cut Ford-Fulkerson “method” Edmonds-Karp algorithm finding negative cycles using DP [book] CS483 - Russell Final Exam Preparation Guide Algorithms Using Max Flow / Min Cut Additional Algorithms from the Book Spring 2023 max bipartite graph matching airplane scheduling image segmentation finding disjoint paths solving flows/circulations (including with demands, lower bounds, and original sources/sinks) [book – ch 7 + lecture] survey design [book – ch 7 optional] project selection [book – ch 7 optional] baseball elimination [book – ch 7 optional] divide and conquer algorithms from ch 5: counting inversions [book] closest pair of points [book] integer multiplication [book] convolutions for the FFT [book] median finding using randomized algorithm [ch 13] 2-3 from this list for randomized algorithms [ch 13]: Contention Resolution Finding the Global Min Cut A Randomized Approx. of MAX 3-SAT Hashing Closest Pair of Points (Randomized) Random Caching Load Balancing Packet Routing CS483 - Russell Final Exam Preparation Guide Spring 2023 CS483 Final Exam Sample Questions You should COMBINE these with the sample questions from the midterm. Important: This part of the guide contains SAMPLE questions for the midterm. The actual exam will have DIFFERENT questions, DIFFERENT question difficulties, a DIFFERENT number of questions, and questions will have weights (DIFFERENT number of points per problem). On the actual exam you will also likely have questions on topics which are not shown here (see the Topics List). Memorizing the answers to these questions will NOT result in a good grade on the exam. However, being able to solve these TYPES of questions WITHOUT assistance is a good sign. Exception: The extra credit question is the same question you will get on the actual exam, and worth the same number of points. It will be given as an anonymous survey question at a later date. What to Bring to the Exam: • • Required: A photo ID, preferably your GMU ID. If you do not have a GMU ID, or your GMU ID is damaged so that the name or picture can’t be read, or you only have a “virtual” GMU ID, you can use another form of photo ID. Driver’s license, learner’s permit, state ID card, or passport are all acceptable. If anyone does not have a photo ID at the time of the exam, I will take a picture of that person and the exam will not be graded until a photo ID is shown (so please don’t skip the exam because you forgot your ID at home). Required: ONE side of an 8.5"x11" sheet of paper with HAND-WRITEN notes (you will submit this with the exam so please put your name on it). The back side is going to be used for scratch paper, so if you choose not to bring notes, you must still bring a blank sheet of paper for scratch paper. EXAMPLE Question Instructions: MULTIPLE CHOICE: Select the correct answer as indicated. If you are directed to select only one item and select more than one, it will be marked as wrong. Not selecting an answer is the same as getting it wrong. ALL OTHER QUESTIONS: Write as much as indicated by the question. ALL words you write will be graded (you can lose points for adding incorrect information). EXAMPLE Exam Timing: The set of sample questions listed below COMBINED with the midterm sample questions for the first half of the semester, should be doable in about three and a half hours WITHOUT any notes or other resources. If it’s taking longer than this (or you need notes to do them quickly), you may need more practice with certain topics. The actual exam will be approximately TWO AND A HALF hours. CS483 - Russell Final Exam Preparation Guide Spring 2023 SAMPLE QUESTIONS WITH ANSWERS (AND TIME ESTIMATES) As part of the midterm review and as part of the last day of class we did (or will do) timed exercises for about 40 minutes. Provided after those classes are longer versions. The combined long versions add up to about 75+ minutes of practice. In addition, below is a template question and a few “new algorithm design” questions which do not have answers (since, as stated, one is only a template and on the others the design is up to you). [Graph Algorithm Template Question] Given the graph on the right perform [a DFT, a BFT, Prim’s, Kruskal’s, Dijkstra’s, Bellman-Ford, Floyd-Warshall] algorithm showing your steps and the final state of any supporting data structures. If you need a starting place for the algorithm, choose node three. [Note that this is a “template question”, choose whichever one you are LEAST comfortable with for practice. You can convert this to a max-flow min-cut problem by choosing a source/sink and directions for the edges.] [New Algorithm Example 1] Design an algorithm for determining the longest monotonically increasing subsequence of a sequence of n numbers. For example, assume the input is 3 7 4 2 8 6. Then the longest monotonically increasing subsequence is 3 4 6 or 3 4 8 both of which have a size of 3, so your algorithm should return a value 3. Note that this is not asking for the longest monotonically increasing consecutive-number sequence, the numbers do not have to be next to each other (as in the example: 3 7 4 2 8 6). This algorithm is solvable in O(n2) time, where n is the number of numbers in the sequence. For your solution, prove your runtime. [New Algorithm Example 2] You want to flip a coin to make decisions in a board meeting (heads with probability 0.5 and tails with probability 0.5). Unfortunately, you have only a “trick coin” that is weighted so that it lands on heads with probability p, and tails with probability 1-p (where 0 < p < 1). Even more unfortunately, you do not know what p is (you can’t remember what was on the instructions when you bought the coin at the joke shop). Give an algorithm that uses the unfair coin to produce a fair coin flip (i.e. you want to tell the board members “it has determined head” or “it has determined tails” with equal probability). You may be as inefficient as you’d like (e.g. flip the unfair coin as many times as you’d like) and you may use scrap paper to track results of coin flips and do some math, but you cannot use other things (such as go to the bank and get a better coin, bend the coin, etc.). State and prove the runtime of your new algorithm. [New Algorithm Example 3] You have a network shaped like a rooted tree, with the root as a source, the leaves as its sinks. All the edges are directed along the paths from the root to the leaves and the edges have various weights. Design an efficient algorithm for finding of a maximum flow in such a network (note this must be more efficient than running a standard max-flow algorithm). Show and prove the efficiency of your algorithm. [+1% Extra Credit] How was your semester? Anything we could have done that would have made it easier, better, or more fun (while still having you learn things)? [This exact question WILL be on the survey.]