5
1/25/08 - Greedy Scheduling Algorithms
Lecture: Greedy scheduling algorithms Reading: Chapter 4.1, 4.2 Interval Scheduling (jobs) Input: A set of pairs (si, ti)Ti=1 0 si ti T, si, ti N Output: A feasible schedule: a subset of the pairs, s.t. t
6
1/28/08 - Five Representative Problems
Lecture: Five representative problems Reading: Chapter 1.2 Earliest Start Time with Pre-emption (1) Preprocess the input to remove jobs whose interval contains another jobs interval (2) Sort the remaining job
Solution Set for CS 482, Prelim 2 April 8, 2008 Questions in red, solutions in black. PROBLEM 1 (20 points)
PART A (15 points) Find a maximum flow and minimum s-t cut in the flow network G shown here. The source and sink are s and t, respectively. Th
Introduction to Algorithms CS 482, Spring 2008
Solution Set 7
(1) First, we prove that Party Invitation is in NP. There is a polynomial-time verier that takes an instance I of Party Invitation consisting of numbers n, k, lists Pi (1 i k), and va
Introduction to Analysis of Algorithms
CS4820 Spring 2013
Sample Homework Solutions
Thursday, January 24, 2013
Based on the original version by Constadino Moraites and Bobby Kleinberg, CS 4820 S12.
1
The Good, the Bad, and the Ugly
This handout discusses
Introduction to Algorithms CS 482, Spring 2008
Solution Set 2
(1) The algorithm restores the websites in decreasing order of ci /ti , where ci is the rate of lost dollars per hour for site i, and ti is the number of hours to nish the job. Analysis
CS 482 FINAL EXAM SOLUTION SET
(1) (10 points) Each of the following statements is false. Give a counterexample to each of them. (1a) (5 points) If G is any graph with non-negative edge costs, and e is any edge such that every minimum-cost spanning
Introduction to Algorithms CS 482, Spring 2008
Solution Set 3
(1) We describe an algorithm Test(S) whose input is a set S of bank cards and whose output is: a bank card x S such that more than half the elements of S are equivalent to x, if any su
Introduction to Algorithms CS 482, Spring 2008
Solution Set 3
(1) (a) Heres a counterexample in which n = 3. Week 1 Week 2 Week 3 1 1 1 0 3 10
i
hi
The optimal solution picks the low-stress job in week 1 and the high-stress job in week 3. The gr
Introduction to Algorithms CS 482, Spring 2008
Solution Set 1
(1) This problem can be solved using a greedy algorithm which always attempts to place the next cell phone tower as far east as possible without leaving a house uncovered. The algorithm
7
1/30/08 - Minimum spanning tree; Krus.
Lecture: Minimum spanning tree; Kruskal's algorithm. Reading: Chapter 4.5 cs482-01-30-08-Audio.mp4 Minimum spanning tree Given G = (V,E) undirected, connected Costs ce > 0 for every e E. Goal: output connect
Introduction to Algorithms CS 482, Spring 2008
Solution Set 6
(1) (a) To compute whether the blood on hand meets the projected demand, one can construct a ow network with 10 vertices. A super-source s. For each blood type x, a pair of vertices ux
28
3/26/08 - NP-complete partitioning pro.
Reduction from 3SAT to HAM. CYCLE Theorem. HAM CYCLE is NP-Complete Proof. (1) Its in NP. Show me the cycle, and I can verify it in O(n) time. (2) The reduction runs in poly(n) time. Let b = length of each
Problem 1.2
Decide whether you think the following statement is true or false. If it is true, give a short explanation. If it is false,
give a counter example.
True or false? Consider an instance of the Stable Matching Problem in which there exists a man
Exercises 1
Decide whether you think the following statement is true or false. If it is true, give a short explanation. If it is false,
give a counterexample. True or false? In every instance of the Stable Matching Problem, there is a stable matching
cont
Problem 4.9 solution
a. If we consider a clique where an edge u has weight 2 and the rest of them having the
weight 3, a MST will certainly contain u, while a minimum bottleneck wont. This shows
that not any minimum bottleneck spanning tree is a MST, also
Problem 27
Lets first try to see what happens if for two different spanning trees of G, there is exactly one
edge that is into one of the spanning trees and not in the second. This case, according the
provided definition, it means that T and T will be nei
8
2/1/08 - Implementing Kruskals algorit.
Lecture: Implementing Kruskal's algorithm using union-nd. Reading: Chapter 4.6 Kruskals Algorithm Sort edges by increasing cost O(mlogn) T< For each edge (u, v) in this order if u, v are not in same componen
Introduction to Algorithms CS 482, Spring 2008
Solution Set 9
(1) There are many correct solutions; here is one. The graph has two vertices s, t and n triples of vertices (ui , vi , wi )n , for a total of 3n + 2 vertices. There are 5n edges, specie
Introduction to Algorithms CS 482, Spring 2008
Solution Set 9
(1) Let T be the number of trucks used by the algorithm, and suppose the trucks are labeled 1, 2, . . . , T in the order that the algorithm loads them up. Observe that for i = 1, 2, . .
13
2/13/08 - Computing RNA secondary str.
RNA: a single-stranded molecule made up of {A, C, G, U} Secondary structure: certain base pairs on same molecule match up Constraints: (i) A pairs only with U C pairs only with G U pairs only with A G pairs
11
2/8/08 - Divide and conquer algorithms.
Lecture: Divide and conquer algorithms in computational geometry: nding the closest pair of points Reading: Chapter 5.4 cs482-02-08-08-Audio.mp4 Closest pair of points Given n numbers x1, x2, . , xn Find i,
29
3/28/08 - NP-complete coloring proble.
NP-complete problems 3SAT, k-SAT (k > 3) IND. SET CLIQUE VERTEX COVER HAMILTONIAN PATH/CYCLE TRAV. SALES. PROB. Reduce FROM . TO (e.g. set cover) if you could use set cover to solve trav salesman in poly tim
27
3/24/08 - NP-complete sequencing pro.
NP: problems whose solution can be eficiently (poly-time) veried. Ex: Compositeness: Given n-bit number x, in x composite? Hint: a pair y,z > 1 such that yz = x. NP-Complete: a problem X which is in NP and ev