




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































■ What makes a graph dense? ■ What makes a graph sparse? ■ What about planar graphs?
■ What can we use BFS to calculate? ■ A: shortest-path distance to source vertex
■ Tree edges, back edges, cross and forward edges ■ What can we use DFS for? ■ A: finding cycles, topological sort
■ What is the bottleneck in Prim’s algorithm? ■ A: priority queue operations
■ What is the bottleneck in Kruskal’s algorithm? ■ Answer: depends on disjoint-set implementation ○ As covered in class, disjoint-set union operations ○ As described in book, sorting the edges
■ What is the running time?
■ What is the running time? ■ When does Dijkstra’s algorithm not apply?
■ Aggregate method: total cost of operation over course of algorithm divided by # operations ○ Example: disjoint-set union ■ Accounting method: “charge” a cost to each operation, accumulate unused cost in bank, never go negative ○ Example: dynamically-doubling arrays
■ Memoization : recursive algorithm, looking up subproblem solutions after computing once ■ Dynamic programming : build table of subproblem solutions bottom-up
■ Optimal substructure ■ Greedy choice property : a locally optimal choice leads to a globally optimal solution
■ Activity selection: Set of activities, with start and end times. Maximize compatible set of activities. ■ Fractional knapsack: sort items by $/lb, then take items in sorted order ■ MST
■ A: A solution can be found in polynomial time
■ A: A solution can be verified in polynomial time
■ A: P ⊆ NP , but no one knows whether P = NP
■ Directed hamiltonian cycle undirected hamiltonian cycle ■ Undirected hamiltonian cycle traveling salesman problem ■ 3-CNF k -clique ■ k -clique vertex cover ■ Homework 7
■ S(k) is true for fixed constant k ○ Often k = 0 ■ S(n) S(n+1) for all n >= k
■ Show formula is true when n = k
■ Assume formula is true for an arbitrary n
■ Show that formula is then true for n+
■ Basis: show that a 0 = (a 0+1^ - 1)/(a - 1) a 0 = 1 = (a 1 - 1)/(a - 1) ■ Inductive hypothesis: ○ Assume a 0 + a 1 + … + a n^ = (a n+1^ - 1)/(a - 1) ■ Step (show true for n+1): a 0 + a 1 + … + a n+1^ = a 0 + a 1 + … + a n^ + a n+ = (a n+1^ - 1)/(a - 1) + a n+1^ = (a n+1+1^ - 1)(a - 1)
■ Behavior of algorithms as problem size gets large ■ Constants, low-order terms don’t matter