CS252 Algorithms Wednesday, 24 April 2024 + Questions + Today - Priority queues - Interface / Abstract Data Type - Objects w/ key + other stuff - Implementation with unsorted array; runtimes of operations - Implementation with heap; runtimes of operations + Dijkstra's Algorithm - compare K&T to Wikipedia - [From Wikipedia, https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode] 1 function Dijkstra(Graph, source): 2 3 for each vertex v in Graph.Vertices: <--- # iterations = N 4 dist[v] ← INFINITY 5 prev[v] ← UNDEFINED 6 add v to Q 7 dist[source] ← 0 8 9 while Q is not empty: <--- # iterations? 10 u ← vertex in Q with min dist[u] 11 remove u from Q 12 13 for each neighbor v of u still in Q: <--- # iterations? 2*|E| 14 alt ← dist[u] + Graph.EdgeWeight(u, v) <--- runtime of EdgeWeight? 15 if alt < dist[v]: 16 dist[v] ← alt 17 prev[v] ← u 18 19 return dist[], prev[] What data structure is Q? operations needed: ? is given v in Q? change dist[v] while v is still in Q (line 16) extract minimum dist[u] from Q (line 10) How are V, E, EdgeWeight stored? Adjacency list (makes line 13 faster) What is its relationship to S in the K&T version? What does prev[u] mean? Runtime analysis of the nested loop--is it just (# iterations outer) * (# iterations inner)? + Minimum spanning trees - What are they? - What are they for? - The problem In: ? Out: ? Brute force?