CSC 282: Design & Analysis of
Efficient Algorithms
Graph Algorithms
Shortest Path Algorithms
Fall 2013
Path Finding Problems
Many problems in computer science
correspond to searching for paths in a
graph from a given start node
Route planning
Packetswitc
Lecture 02  5 September 2013
There will be an assignment posted on the course's web site later today:
http:/www.cs.rochester.edu/u/www/courses/282/fall2013/
(If you loose this URL, you can get to through Blackboard.)
The assignment is due one week from t
1 Oct 2013 
Greedy Algorithms
Spanning Trees, Disjoint Sets, Path Compression in Union Find
Greedy algorithms: "myopic"  only looking nearby
 repeatedly pick the next part of the solution that looks best
 not in GENERAL an optimal strategy
eg: not g
CSC 282 17 Oct 2013
Dynamic programming continued: Knapsack
Problem from last class: how to recover alignment from edit distance algorithm:
for i = 0 to m:
E[i,0] = i
for j = 0 to n:
E[0,j] = j
for i = 1 to m
for j = 1 to n
E[i,j] = mincfw_ 1+E(i1,j)
Oct 15 Dynamic programming.
Reading: [DVP Ch 6]. Longest increasing subsequences. Edit distance.
Next class: Knapsack.
Two "thousand pound gorillas" of algorithms:
dynamic programming
linear programming
Dynamic program: approach to algorithm design that
Lecture 6
24 Sept 2013
 Go over exam
 representing long numbers
variable length array vs linked list
compare two numbers
test bit 0
test bit k
shift by 1
shift by k
inclass exercise:
"round up to power of two" using variable length array A[i]
making li
Linear programming (part 4 of CSC 282),
http:/www.cs.rochester.edu/~stefanko/Teaching/15CS282
IMPORTANT: Write each problem on a separate sheet of paper. Write
your name on each sheet. (Why? To speed up the grading we will use parallelizationeach problem
Greedy algorithms/dynamic programming (part 1 of CSC 282),
http:/www.cs.rochester.edu/~stefanko/Teaching/15CS282
IMPORTANT: Write each problem on a separate sheet of paper. Write
your name on each sheet. (Why? To speed up the grading we will use paralleli
Graph Algorithms (part 2 of CSC 282),
http:/www.cs.rochester.edu/~stefanko/Teaching/15CS282
IMPORTANT: Write each problem on a separate sheet of paper. Write
your name on each sheet. (Why? To speed up the grading we will use parallelizationeach
problem wi
Linear programming (part 3 of CSC 282),
http:/www.cs.rochester.edu/~stefanko/Teaching/15CS282
IMPORTANT: Write each problem on a separate sheet of paper. Write
your name on each sheet. (Why? To speed up the grading we will use parallelizationeach problem
Graph Algorithms II (part 2 of CSC 282),
http:/www.cs.rochester.edu/~stefanko/Teaching/15CS282
IMPORTANT: Write each problem on a separate sheet of paper. Write
your name on each sheet. (Why? To speed up the grading we will use parallelizationeach
problem
How quickly can we add nbit numbers?
How quickly can we multiply nbit numbers?
for i from 0 to n1 do (O(n^2)
if b[i] = 1 then
r< r+2
2n bit
a = A1 A0
b = B1 B0
want : a*b = A0B0 + 2^n/2 (A1B0 + A0B1) + 2^n *(A1B1)
compute E = A0B0
F = A1B1
a = 1011 10
Lecture 03  10 September 2013
Big news: assignments are due on Friday at 2pm, rather than start of class Thursday.
The first inclass exam is September 17.
Where we left off.
Euclid's Rule:
For integers x >= y > 0, gcd(x,y) = gcd(x mod y, y)
function Euc
Lecture 01  3 September 2013
 Change of text book  Algorithms, S. Dasgupta, C. Papadimitriou, U. Vazirani
 Will schedule workshop sessions starting next week
 introduce TA's  Tim Kopp (graduate TA), Yan Xing & Sean Esterkin (undergraduate TAs)
Class
Lecture 19: Practice with Reductions
03 Dec 2013
In class exercise:
2SAT is in P
Horn SAT is in P
Prove that 2SAT U Horn is NPComplete.
What two things are needed?
 2SAT U Horn is in NP
 Reduction from what to what?
From 3SAT to 2SAT U Horn
One soluti
Lecture 18:
Introduction to NP completeness
 this class has focused on algorithms for problems that can be solved in polynomial time, the class P.
Draw class P
Examples of problems in P  and harder similar problems
shortest path  longest path (not nece
Lecture 13 Memoization
22 Oct 2013
Memoization  technique for converting a recursive algorithm directly into a dynamic programming algorithm.
Idea: cache values previous computed in a hash table.
Before initial call to f(x):
h = makeHashtable;
function f
Duality
CSC 282
Duality
Change of
representation by
exchanging parts of one
type with parts of
another part
Example: Dual of a
planar graph: exchange
vertices and faces
Duality in Linear
Programming
Exchange variables and constraints
Exchange maximization
linear programming: lp_solve,
max flow, dual
CSC 282
Fall 2013
lp_solve
lp_solve is a free linear (integer)
programming solver based on the revised
simplex method and the Branchandbound method for the integers
http:/lpsolve.sourceforge.net/
Example: Prof
Quantum Computing
CSC 282 Fall 2013
Quantum mechanics
is the operating
system that other
physical theories run
on as applications.
Biology
Chemistry
Physics
!
Scott Aaronson
Quantum Mechanics
Mathematics
Inevitability of Quantum
Mechanics
Quantum mechanic
NPComplete Problems
CSC 282
The Story So Far
NP
Decision problems that can be solved in polynomial time on a nondeterministic Turing Machine
Search problems whose solution can be veried in polynomial time
Reduction: a polynomial time transformation AB
Of
Simplex
CSC 282
Dening inequalities
for A and C?
Case 1: Vertex is Origin
Origin is optimal iff all ci 0
Otherwise:
Release some tight
constraint xi
Increase xi until some other
inequality becomes tight
Increase x2 until
it runs into
constraint 3
stopping
Lecture 15  Linear Programming
Imperative programming
vs
Declarative programming
 specify what is to be solved, not how to solve it
Declarative programming:
specify a problem in terms of:
 Constraints on set of possible solution
 Optimization criteria
Lecture 11 22 Oct 2013
Chain matrix multiplication. all pairs shortest paths.
Optimizing matrix multiplication.
A x B x C x D
examples from book:
Given m x n and n x p matrices (draw)
How many multiplications?
mnp multiplications.
Is matrix multiplicatio
Lecture 05  17 September 2013
The first inclass exam is this coming Tuesday September 17.

discussion of assignment 1.
Problem 7:
First possible solution: assumes that length(z) remains same as length(x):
n = log(x)
m = log(y)
T(m) = T(m1) + O(n^2)
=
Lecture 04  12 September 2013
Big news: No final exam. Instead, there are 5 inclass exams and 5 assignments, each worth 10% of final grade.
The first inclass exam is this coming Tuesday September 17.
*
Today we will be talking about what are called "se
Variables: x1,.,xn, ys, zs etc
linear function (of the variables)
a1x1+a2x2+.+anxn
where ai<R
sum of linear functions is a linear function
 linear constrainsts
linear function = Constant equality constraints
or
linear function >= Constant inequality con