Teaching plan
Reading Assignment
Dasgupta et al's book MIT (Cormen et al) book
Written Assingment
Week 1, Jan 14 Week 2, Jan 21 Week 3, Jan 28 Week 4, Feb 4 Week 5, Feb 11 Week 6, Feb 18 Week 7, Feb 25 Week 8, Mar 4 Week 9, Mar 11 Week 10, Mar 18 Week 11,
Polynomials & FFT Reading Cormen et al. : Chapter 30 (recommended) Dasgupta et al. : 2.6 Lipson, Elements of Algebra & Algebraic Computing (available in the library)
Fast Fourier transform: math & algorithm
From Wikipedia, the free encyclopedia A fast Fou
More NP complete problems
3SAT Clique Knapsack 3D matching Vertex Vertex Cover subset sum Hamiltonian path set cover Hamiltonian path TSP
Todays lecture sketches some reductions. You should fill in the details and proof of correctness.
1
NPThe Knapsack pr
The first NP-complete problem
The Satisfiability problem (SAT): Given a formula F, find a satisfying truth assignment or else report that none exists. E.g., (x1 x2) (~ x2) : x1 = true, x2 = false x2 (~ x2) : no satisfying assignment exists. Theorem [Cook
NP-completeness
Most recognized theoretical aspect of CS Methodology for showing some hard problems cant be solved efficiently. Reading: Dasgupta et al. Chapter 8 Cormen et als book (not recommeded)
1
No efficient algorithms
A simple search problem withou
Edmond & Karp Algorithm
Identical structure as the Ford and Fulkerson algorithm.
Start with zero flow f (i.e., f(u,v)=0 for all (u,v) E). Repeat Construct the residual network Gf with forward & backward edges. Find a path p with residual capacity rc from
Faster maximum flow algorithms
Notations.
n = number of vertices; m = number of edges; integer C = max capacity.
Ford & Fulkerson: O(nmC) time. Scaling FF: O(m2 log C) time. Edmond & Karp: O(m2 n) time; edge capacity can be arbitrarily large real number.
Maximum Maximum flow
To remember: max flow = min cut Reading
Dasgupta: Chapter 7.2 Cormen et al. : Chapter 26.1-2
Assignment 1
Average 29.4 / 50 (expectation: 30 35) Max 45 / 50 Difficulty rating: ~4 (expectation: 4) Mid-term (Friday 10:40 11:35) Divide a
All-pairs shortest paths
Input:
a weighted directed graph G = (V,E) edge weight w(e) can be +ve or ve;
To find: the shortest (smallest weight) path between all pairs of vertices. Assumption: G has no negative cycles. Using Bellman-Ford algorithm, we can f
Sequence similarity
DNA: From a computer scientists viewpoint, DNA is a sequence of characters chosen from the alphabet cfw_A, C, G, T. Human genome contains ~3 billion characters.
An A4 paper contains 5 to 10 K characters, you need ~.5 million sheets she
Shortest paths revisited
Input:
a weighted directed graph G = (V,E) edge weight w(e) can be +ve or ve; vertexes s and t
To find: the shortest (smallest weight) path from s to t (s-t path). path). Recall that the proof of Dijkstras algorithm fails if there
Dynamic programming
Greedy algorithm. Build up a solution incrementally by optimizing some local criterion. Remark. May not give optimal solutions; when yes, it often involves non-trivial analysis. Divide and conquer. Break up a problem into two subproble
Interval Scheduling
Interval scheduling. Job j starts at sj and finishes at fj. Two jobs are compatible if they don't overlap. Goal: find the largest subset of mutually compatible jobs.
TIME
1
Interval Scheduling: Greedy Algorithms
Greedy template. Sort t
Greedy Algorithms
Huffman Encoding
Dasgupta et al. 5.2 Cormen et al. 16.3
Greedy algorithms
Characterization: Build up a solution in small steps; Each step makes a choice/decision based on a simple but probably short-sighted objective. Hope for the best:
Shortest paths
Dasgupta et al. 4.1-4.5 Cormen et al. 24.2-24.3
Shortest Paths in a Graph
Input: A directed graph G = (V, E), each edge e is associated with a positive weight (length), denoted w(e). Source s, destination t. Shortest path problem: Find a sh
Directed graphs
Paths, cycles, strongly connected, sink/source of acyclic graphs, strongly connected components DasGupta et al. 3.3, 3.4 Cormen et al.: 22.4, 22.5
Directed graphs (Digraphs)
Each edge has an orientation. We distinguish an edge from u to v
Minimum (weight) spanning trees
Input: A connected undirected graph G = (V, E); each edge e in E has a weight or cost, denoted w(e). To find: MST = a subset of edges T E such that T is a spanning tree whose sum of edge weights is minimized.
5 5 1
e
4
e b
Graphs
Graphs: a simple way of representing pairwise relationships among a set of objects. Graph theory: an old subject with modern applications. Graph algorithms - algorithms for graph problems.
1
Reading
Dasguta et al. Chapter 3 MIT book: Chapter 3.1 3
Divide and Conquer
Week 1 Reading
Examples Mergesort O(n log n) time Long integer multiplication O(n log n) time Finding the closest pair of points O(n log n) time Matrix mulitplication O(n2.81) time Median O(n) time
Dasgupta 2.1-2.5 Cormen 28.2, 33.4
1
0250B Algorithms (advanced class)
Regular class focuses on how basic algorithms work applications of algorithms Advanced class puts more emphasis on problem solving skills mathematical proofs (why it works) complexity analysis (how fast it is). Final exam
CS 0250B Design and Analysis of Algorithms
January 14, 2009
Lecturer: Professor Tak-Wah Lam (CYC 409, [email protected]) Tutor: Edward Wu ([email protected]) Homepage: http:/www.cs.hku.hk/~c0250b Lecture: Wed 10:40 am - 12:35 am and Fri 10:40 am - 11:35 am Wh
CSIS 0250B Design and Analysis of Algorithms
Assignment 6 Sampled Solution
1
Figure 1: Solution for question 1 by Ng Wai Lun
2
Figure 2: Solution for question 2 by Feng Letain
3
Figure 3: Solution for question 3 by Lam Ka Chan
4
CSIS 0250B Design and Analysis of Algorithms
Assignment 6 Due: 11:55 PM, 1 May, 2009 1. Let G = (V, E ) be a degree-d, undirected graph, where d > 2. (I.e., every node has at most d neighbors.) An unrelated vertex set U of G is a subset of V such that no
CSIS0250B Design and Analysis of Algorithms Sample Solution to Assignment Five Questions 1 - 5 carry 20 marks each. 1. The input to the Clique-3 problem consists of a graph G and a positive integer b where the degree of G is bounded by 3. CLIQUE-3 is the
CSIS 0250B Design and Analysis of Algorithms
Assignment 4 Due: 11:55 PM, Apr 16, 2009 1. Consider the CLIQUE problem restricted to graphs in which every vertex has degree at most 3. Call this problem CLIQUE-3. (a) Prove that CLIQUE-3 is in NP. (b) What is
CSIS 0250B Design and Analysis of Algorithms
Assignment 4 Sampled Solution 1. As matching M of G with n 1 edges are given, we have 1 vertex on each side of the bipartite graph that are not matched. We construct a directed graph G from G. For each edge e(u
CSIS 0250B Design and Analysis of Algorithms
Assignment 4 Due: 11:55 PM, Apr 2, 2009 Below we assume that all networks have integer edge capacities, and the ow being considered have integer value. In our analysis, you can express the time complexty in ter
CSIS0250B Design and Analysis of Algorithms Sample Solution to Assignment Three Questions 1 - 4 carry 25 marks each. 1. (Solution by Tong Chiu Man) Assume U = n=1 ai is a multiple of three and ai U i 3 for all i = 1, 2, , n. Otherwise, it is not possible
CSIS 0250B Design and Analysis of Algorithms
Assignment 3 Due: 11:55 PM, Mar 12, 2009 1. Given positive integers a1 , a2 , , an , devise a dynamic programming algorithm to determine whether it is possible to divide the n integers into three disjoint subse