CSIS0250/COMP3250A
Lecture 10: Prim's Algorithm
(Chapter 5.1)
Recap of Graph Algorithms
DFS is much like walking in a maze:
- Basic exploration step: When reaching some vertex u,
pick an adjacent vertex v and (recursively) explore v.
- If we hit a dead e

CSIS0250/COMP3250A
Lecture 15: Knapsack Problem
What is the knapsack problem?
Let there be n items and a knapsack with capacity W.
Each item i has weight wi > 0 and has value vi > 0.
Goal: fill the knapsack with a subset of items to maximize the
tota

CSIS0250/COMP3250A
Lecture 14: Edit Distance
What is edit distance?
In computer science, edit distance is a way of quantifying how
dissimilar two strings (e.g., words) are to one another by
counting the minimum number of editing operations required to
tra

CSIS0250/COMP3250A
Lecture 9: Bellman-Ford Algorithm
(Chapter 4.6)
Shortest path in the presence of negative edges
Negative edges are natural in some applications.
The correctness of Dijkstra depends on the fact that no edge
has negative weight.
Dijkstr

CSIS0250/COMP3250A
Lecture 7: Breadth-First Search
(Chapter 4.1 and 4.2)
Some Definitions
A path is a sequence of edges in which the end vertex of an
edge equals the start vertex of the following edge.
a
a
b
b
c
c
d
d
Not a path from a to d,
the direction

CSIS0250/COMP3250A
Lecture 8: Dijkstra Algorithm
(Chapter 4.3, 4.4, and 4.5)
Edges with Lengths
We now consider weighted graph, i.e., every edge (u,v) is
associated with a length L(u,v).
s
23
b
9
18
14
f
15
5
30
d
16
20
44
2
6
2
11
e
g
CSIS0250A
c
19
6
t

CSIS0250/COMP3250A
Lecture 17: Applications of
Network Flow
Recap: Flow Network
A flow network consists of a directed graph G = (V, E), where
each edge (u, v) is associated with a capacity c(u, v) 0, a
source vertex s, and a sink vertex t.
Example:
v1
12

CSIS0250/COMP3250A
Lecture 16: Floyd-Warshall Algorithm
Recall the Bellman-Ford algorithm
For graphs that have negative edges, but do not have negative
cycle, we can use the Bellman-Ford algorithm to solve the
single source shortest path problem.
Note: We

CSIS0250/COMP3250A
Lecture 17: Network Flow
Flow Network
A flow network consists of a directed graph G = (V, E), where
each edge (u, v) is associated with a capacity c(u, v) 0, a
source vertex s, and a sink vertex t.
Example:
v1
12
v3
16
20
10
s
9
7
13
4

CSIS0250/COMP3250A
Lecture 12: Greedy Algorithm for
Scheduling Problems
Example: Basic Job Scheduling
Input: A set of n jobs (homework assignments),
where each job j is associated with a size sj and a deadline dj.
Output: An assignment of jobs to time sl

CSIS0250/COMP3250A
Lecture 11: Kruskal's Algorithm
(Chapter 5.1)
Announcement
Midterm on March 18 (the Friday after the reading week)
- 90 mins (starts at 9:40am)
- 3 problems
- 10% of the final evaluation
CSIS0250A
2
Zhiyi Huang
Minimum Spanning Tree
D

CSIS0250/COMP3250A
Lecture 13:
Longest Increasing Subsequence
(Dynamic Programming)
Dynamic Programming (Chapter 6)
Dynamic programming is a more ecient way for implementing
certain recursive algorithms.
Examples:
- Computing the Fibonacci numbers.
- Be