CS252 Algorithms Wednesday, 1 May 2024 + Big-shot in town! - Lorrie Cranor - CS Prof, CMU - Director of the CyLab Security & Privacy Institute - Usable security, usable privacy - Today, 5:00, Weitz cinema Do We Actually Have a Choice? Why Navigating Privacy Choice is Difficult and How We Can Make it Better - Tomorrow, 9:30-10:30, Olin 306 Hang out with her! - Tomorrow, 3:30, AND 329 (usual CS Tea setup) Real Humans, Simulated Attacks: Usability Testing with Attack Scenarios + Today - Some greedy algorithm loose ends - What's up with Monday's exam? - Getting started on divide-and-conquer and recurrences + Friday - Exam prep: examples, revisiting topics on request, etc. as long as it takes - Extra time? - Recurrences by hand - General solution of recurrences of the form T(n) = aT(n/b) + cn^k; T(1) = d ====== + Loose end #1: notes on problem set 6 - #1 intended to be easy - #2 (a) intended to be easy (b) easy or medium, depending on how you interpret it just state your assumption - #3 is a cool problem, but pretty hard, especially parts (b) and (c) + Loose end #2: Union-Find - Operations - Initialize O(N) - Find-Set or Find-Component... O(1)? O(log N)? - Union O(1)? O(log N)? - Why do we want this? - How does it work? - How does it buy us running time? [From CLRS] Kruskal(G=(V,E,W)) E' = ∅ for v in V: MAKE-SET(v) sort E in nondecreasing order by weight for (u,v) in E: # in sorted order if FIND-SET(u) != FIND-SET(v): E'.ADD((u,v)) UNION(u,v) return (V,E',W) [Some pseudocode] INITIALIZE for k = 0 to n-1 parent[k] = k size[k] = 1 FIND(int u) if parent[u] == u return u else return FIND(parent[u]) UNION(u, v) rootU = FIND(u) rootV = FIND(v) if rootU == rootV: return if size[rootU] > size[rootV] parent[rootV] = rootU size[rootU] += size[rootV] else parent[rootU] = rootV size[rootV] += size[rootU] ====== + The exam - Monday, May 6, in class like last time - Review document from Layla posted on our website - Topics - Greedy algorithms in general, including the "greedy stays ahead" style of proof - Interval scheduling, including the variants you read about even if we didn't do them in class - Single-source shortest paths in graphs including Dijkstra's Algorithm - Minimal Spanning Trees including Kruskal, Prim, and Reverse-Delete - Cut Rule and Cycle Rule - Union-Find data structure - Things to think about - In any of our algorithms, where are the runtime crunch points? (e.g., why would you want to use a heap or a Union-Find?) - If you're alone with a piece of paper and your brain, can you write out all the algorithms listed above (and understand what you're writing)? - Can you construct example instances of the relevant problems and walk through the corresponding algorithms? - Cook up your own true/false problems and solve them + Break + Divide and Conquer - Generic - split into subproblems of the same type - solve the subproblems recursively - combine the subproblem solutions to solve the big problem - Mergesort speedrun - Let's do a dumb one: sum of an array of integers - Recurrences