First, let's recall the the definition of the approximation ratio of an algorithm. Suppose that we are
trying to solve some combinatorial optimization problem
P
where we are given some input
I
, and want to give an algorithm
ALG
which produces an output
A
Term Test # 1
Summer 2012
CSC 373 H1
Duration: 80 minutes
Aids Allowed: NONE (in particular, no calculator)
Student Number:
Last (Family) Name(s):
First (Given) Name(s):
Do not turn this page until you have received the signal to start.
In the meantime, p
Stanford University CS261: Optimization
Luca Trevisan
Handout 15
February 24, 2011
Lecture 15
In which we look at the linear programming formulation of the maximum flow problem,
construct its dual, and find a randomized-rounding proof of the max flow - mi
CSC 373: Algorithm Design and Analysis
Lecture 3
Allan Borodin
January 11, 2013
1 / 13
Interval colouring
Interval Colouring Problem
Given a set of intervals, colour all intervals so that intervals having
the same colour do not intersect
Goal: minimize th
1. Compute maximum flow f and minimum cut (S, T ).
6/8
a
6/6
c
7/10
13/15
s
0/5
10/10
7/7
d
9/9
e
0/2
16/24
0/3
3/5
9/14
b
t
f
6/6
g
Max flow f with value |f | = 22. Min cut (S, T ) where S = cfw_s, a, b, c, d, f, g and T = cfw_e, t
with capacity c(S, T )
Dynamic Programming
Friday, January 27, 2017 3:11 PM
Different Optimal sub-structure:
Problem 1-Chain Matrix Multiplication:
Dene: cost of multiply two matrices
A1 of dimension n x p and A2 of dimension p x n
as npm (n times p times m)
Matrix multiplicati
=
CSC 373 Sample Solutions for Tutorial 1 Fall 2015
=
1. Algorithm:
d = [1, 5, 10, 25] # coin values (aka "denominations")
k = 3 # start with largest denomination
C = [] # list of coins used to make change
while A > 0:
while A < d[k]:
# Try the nex
CSC373, Winter 2007
Tutorial 2 Notes
Authors: Qiyang Li, Denis Pankratov
Important Concepts
In order for a problem to admit a greedy algorithm, it needs to satisfy two properties.
Optimal Substructure: an optimal solution of an instance of the problem con
2 Mergesort, Integer Multiplication
Monday, January 9, 2017 3:09 PM
Divide and Conquer: To solve instance of size n
(1) divide it into 2 or more sub instace of smaller size, e.g.
n
2
(2) solve suv instaces recursively
(3) combine solutions to (2) to get
3 Closest Pair of Pts
Wednesday, January 11, 2017 3:12 PM
Def: p1, p2 R , d(p1, p2) be the distance
Input: array A of n pts in 2D, n 2
Output: (p1, p2) such that p1, p2 appear in A d(p1, p2) = mincfw_d(A[i], A[j]) | i j
Meature of interest: number of inte
1 Modular Exponentiation
Friday, January 6, 2017 3:26 PM
Modular Exponentiation:
Input: a, b, m N
Output: a modm
Meature of Interests: number of modular multiplications
Solution 1- Brute Force: Cost b (measure)
Solution 2- Repeated Squaring:
mod m, ., a
CSC 373 Midterm 2, Winter 2010
Name: _
Student Id: _
Please put your name on each page of this midterm.
Advice: The midterm has three questions, together worth 50 points. We expect you to
spend as many minutes on a problem as it is worth points. You shoul
(a)
5/5
a
c
9/10
4/4
11/20
s
t
0/3
11/12
6/6
13/15
b
d
7/7
(b)
a
s
c
5
1
9
6
9
11
3
2
1
t
4
13
b
d
7
S
11
T
(c)
z
x3
x4
x5
=
5x1
= 2 x1
= 4 x1
= 3
+x2
+x2
x2
x2
Basic solution = (0, 0, 2, 4, 3) (in the order (x1 , x2 , x3 , x4 , x5 ), entering var = x1 ,
CSC373
Term Test 1
6 February 2017
Duration: 50 minutes
Aids allowed: one single-sided hand written 8.5 11 aid sheet
Student number:
Last (Family) Name(s):
First (Given) Name(s):
Do not turn this page until you have received the signal to start.
In the me
8 Knapsack
In Chapter 1 we mentioned that some NPhard optimization problems allow
approximability to any required degree. In this chapter, we will formalize this
notion and will show that the knapsack problem admits such an approxima-
bility.
Let H be an
=
CSC 373 Sample Solutions for Tutorial 1 Fall 2015
=
1. Algorithm:
d = [1, 5, 10, 25] # coin values (aka "denominations")
k = 3 # start with largest denomination
C = [] # list of coins used to make change
while A > 0:
while A < d[k]:
# Try the nex
Greedy Algorithms: The Fractional Knapsack
Version of November 5, 2014
Version of November 5, 2014
Greedy Algorithms: The Fractional Knapsack
1 / 14
Outline
Outline
Introduction
The Knapsack problem.
A greedy algorithm for the fractional knapsack problem
CMSC 451: SAT: Coloring, Hamiltonian
Cycle, TSP
Slides By: Carl Kingsford
Department of Computer Science
University of Maryland, College Park
Based on Sects. 8.2, 8.7, 8.5 of Algorithm Design by Kleinberg & Tardos. Boolean Formulas
Boolean Formulas:
Var
CSC373, Winter 2007
Assignment 3 Sample Solutions
1. (a) The IP dual is
Minimize
yT b
Subject to y T A cT
y 0
y Zn
Claim 0.1 (Principle of weak duality for IP). If x
b Zn is a solution to the primal,
n
T
T
and yb Z is a solution to the dual, then c x
b yb
CSC373, Winter 2017
Tutorial 6 Notes
Author: Qiyang Li
7.8 - Minimize Maximum Absolute Difference
Question (General)
You are given n points in a 2-D plane, cfw_(x1 , y1 ), (x2 , y2 ), . . . , (xn , yn ). Find a line ax + by = c such that
max |axi + byi c|
CSC373: Algorithm Design, Analysis & Complexity
Winter 2017
Tutorial 3: Polynomial Multiplication via Fast Fourier Transforms
TA: Eric Bannatyne
January 30, 2017
Today, were going to learn about the fast Fourier transform, and well see how it can be appli
Algorithms CMSC-37000
Divide and Conquer: The KaratsubaOfman algorithm
(multiplication of large integers)
Instructor: Laszlo Babai
The KaratsubaOfman algorithm provides a striking example of how the
Divide and Conquer technique can achieve an asymptotic s
CSC373
Term Test 2
March 13, 2017
Duration: 50 minutes
Aids allowed: one single-sided hand written 8.5 11 aid sheet
Student number:
Last (Family) Name(s):
First (Given) Name(s):
CDF account:
Do not turn this page until you have received the signal to star
CSC373, Winter 2007
Instructor: Denis Pankratov
Algorithm Intro: Repeated Squaring, Binary Search
Repeated Squaring
In the problem of modular exponentiation, you are given natural numbers a, b and m and you are
required to output ab mod m. For the purpose
CSC373, Winter 2007
Tutorial 7
CLRS 34-1 (a)
Definition 0.1. Let G = (V, E) be an undirected graph. A subset S V is an independent set
in G if there are no edges between vertices in S.
Independent Set Problem
Input: G - undirected graph.
Output: S - large
CSC 373 - Algorithm Design, Analysis, and Complexity
Summer 2016
Assignment 1- Solutions: Due Sunday June 12, 10PM
Please follow the instructions provided on the course website to submit your assignment. You
may submit the assignments in pairs. Also, if y
CSC 373 - Algorithm Design, Analysis, and Complexity
Summer 2016
Assignment 3: Due Tuesday August 2nd, 10PM
Please follow the instructions provided on the course website to submit your assignment. You
may submit the assignments in pairs. Also, if you use
CSC 373
Tutorial # 3
Instructor: Milad Eftekhar
Problem 1. Fractional Knapsack (greedy algorithm). There are n items I1 , , In . Item Ii has weight wi and
worth vi . All these items can be broken into smaller pieces. We have a knapsack with capacity S and
CSC 373
Tutorial # 2
Instructor: Milad Eftekhar
Problem 1. If graph G is connected and contains more than n 1 edges (where n = |V |, as usual), and if there
is a unique edge e with minimum cost, then is e guaranteed to be in every MST of G? If so, give a