Prev:
W4 , Next:
W6
Zoom:
Link , TopHat:
Link (936525), GoogleForm:
Link , Piazza:
Link , Feedback:
Link , GitHub:
Link , Sec1&2:
Link
Slide:
Go All Prev Next
# Slides and Notes
📗 From sections 1 and 2:
➩ Graph search notes:
Link
➩ DFS and BFS notes:
Link
# Depth First Example
ID:
Confirm
📗 [1 point] List the nodes in use
Depth First
Breadth First
Traversal.
➩ Node names: and Adjacency matrix:
📗 Queue:
📗 Nodes:
# Breadth First Example
ID:
Confirm
📗 [1 point] List the nodes in use
Depth First
Breadth First
Traversal.
➩ Node names: and Adjacency matrix:
📗 Queue:
📗 Nodes:
# Time Complexity
📗 V: the number of nodes in graph.
📗 E: the number of edges in graph.
📗 Depth first:
➩ Adjacency matrix: \(O\left(V^{2}\right)\).
➩ Adjacency list: \(O\left(V + E\right)\).
📗 Breadth first:
➩ Adjacency matrix: \(O\left(V^{2}\right)\).
➩ Adjacency list: \(O\left(V + E\right)\).
# Dijkstra's Algorithm Example
ID:
Confirm
📗 [1 point] Find the shortest path from node A to every other node using Dijkstra's Algorithm.
➩ Node names: and Adjacency matrix:
📗 Queue:
📗 Nodes:
# Python Implementation
📗 BFS and DFS can be implemented in Python using
deque (deck):
Wikipedia .
➩ Stack: deque.append(...) and deque.pop().
➩ Queue: deque.append(...) and deque.popleft().
📗 Dijkstra's Algorithm priority queue can be implemented in Python using
heapq:
Wikipedia .
➩ Priority queue: heapq.heappush(...) and heapq.heappop().
➩ Visualization of a heap:
Link .
📗 Example:
# Questions?
test dfs,bfs,dks q
📗 Notes and code adapted from the course taught by Professors Gurmail Singh, Yiyin Shen, Tyler Caraza-Harter.
📗 If there is an issue with TopHat during the lectures, please submit your answers on paper (include your Wisc ID and answers) or this Google form
Link at the end of the lecture.
📗 Anonymous feedback can be submitted to:
Form . Non-anonymous feedback and questions can be posted on Piazza:
Link
Prev:
W4 , Next:
W6
Last Updated: March 31, 2026 at 12:33 AM