Network Flow Problems
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
Outline
Network Flow Problems
Ford-Fulkerson Algorithm
Bipartite Matching
Min-cost Max-flow Algorithm
Network Flow Problems
2
Network Flow Problem
A type of network optimization
Basic Graph Algorithms
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
Outline
Graphs
Adjacency Matrix and Adjacency List
Special Graphs
Depth-First and Breadth-First Search
Topological Sort
Eulerian Circuit
Minimum Spanning Tree (MST)
Strongly Con
Introduction
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
Welcome to CS 97SI
Introduction
Programming Contests
How to Practice
Problem Solving Examples
Grading Policy
2
Coaches
Officially: Jerry Cain
Actually: Jaehyun Park
3
Why Do Programming C
Mathematics
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
Outline
Algebra
Number Theory
Combinatorics
Geometry
Algebra
2
Sum of Powers
n
X
k2 =
k=1
X
k3 =
1
n(n + 1)(2n + 1)
6
X 2
k
=
Pretty useful in many random situations
Memorize above!
Algebr
Combinatorial Games
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
Combinatorial Games
Turn-based competitive multi-player games
Can be a simple win-or-lose game, or can involve points
Everyone has perfect information
Each turn, the player changes
String Algorithms
Jaehyun Park
CS 97SI
Stanford University
June 30, 2015
Outline
String Matching Problem
Hash Table
Knuth-Morris-Pratt (KMP) Algorithm
Suffix Trie
Suffix Array
String Matching Problem
2
String Matching Problem
Given a text T and a pattern
Shortest Path Algorithms
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
Shortest Path Problem
Input: a weighted graph G = (V, E)
The edges can be directed or not
Sometimes, we allow negative edge weights
Note: use BFS for unweighted graphs
Outp
Shortest Path Algorithms
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
Outline
Cross Product
Convex Hull Problem
Sweep Line Algorithm
Intersecting Half-planes
Notes on Binary/Ternary Search
Cross Product
2
Cross Product
Arguably the most importan