Lecture Notes on 25 Apr 2022 * Dijkstra's Single Source Shortest Path Algorithm - Choose a starting vertex. - Create a table with all the other vertices in the graph. - From the starting vertex fill the table with the cost of visiting all the other vertices. - Go to the vertex with the lowest cost and update the cost of visiting all the other vertices from the starting vertex. - Go to all the other vertices in order of increasing cost and update the costs of visiting the other vertices from the starting vertex. - When you have visited all the vertices that you can visit from the starting vertex then you are done. * Worked out example using Dijkstra's Algorithm https://www.cs.utexas.edu/users/mitra/csSpring2022/cs313/notes/Dijkstra.pdf * Let us look at some fun puzzles that you can use graphs to solve: https://www.cs.utexas.edu/users/mitra/csSpring2022/cs313/notes/Graph_Puzzles.pdf * Here is one solution: https://www.cs.utexas.edu/users/mitra/csSpring2022/cs313/notes/Graph_Images.pdf * Some additional terms: https://www.cs.utexas.edu/users/mitra/csSpring2022/cs313/notes/Graph_Terms.pdf Dynamic Programming is a computational problem solving paradigm that relies on two factors - overlapping sub-problems and optimal substructure. In dynamic programming you break a problem into sub-problems and use the optimal solution of the sub-problems to solve the main problem. In dynamic programming you store the results of the sub-problems so that you do not repeat the same computations (otherwise known as memoization). A great example of overlapping sub-problems is the computation of terms in the Fibonacci series. The general term in the Fibonacci series can be written as fib (n) = fib (n - 1) + fib (n - 2) fib (n - 1) = fib (n - 2) + fib (n - 3) fib (n - 2) = fib (n - 3) + fin (n - 4) A problem must have optimal substructure property if it can be solved by dynamic programming. Consider the shortest path algorithm that we did last class. If a vertex q lies on the shortest path from p to r then the shortest path from p to r is the sum of the shortest path from p to q and the shortest path from q to r.