CS 170
Algorithms
Spring 2014
Elchanan Mossel
HW 1
Due January 31st, 6:00pm
Instructions: You are welcome to form small groups (up to four people) to work through the homework,
but you must write up all your solutions strictly by yourself, and you must ac
U.C. Berkeley CS170 : Algorithms, Fall 2014
Professor: Elchanan Mossel
Midterm 1
Feb 20, 2014
Midterm 1
Name:
SID:
TA:
Section Time:
Person on Right:
Person on Left:
Answer all questions. Read them carefully rst. Be precise and concise. Write in the space
U.C. Berkeley CS170 : Algorithms, Fall 2014
Professor: Elchanan Mossel
Midterm 1
Feb 20, 2014
Midterm 1 Solutions
Name:
SID:
TA:
Section Time:
Person on Right:
Person on Left:
Answer all questions. Read them carefully rst. Be precise and concise. Write in
CS 170
Algorithms
Spring 2014
Elchanan Mossel
1. (16 pts.)
HW 5
Shortest Path Currency Trading
a) Represent the currencies as the vertex set V of a complete directed graph G. To nd
the most advantageous ways to converts cs into ct , you need to nd the pat
CS 170
Algorithms
Spring 2014
Elchanan Mossel
HW 5
Due March 7th, 6:00pm
1. (16 pts.) Shortest Path Currency Trading
Shortest path algorithms can be applied in currency trading. Let c1 , c2 , . . . , cn be various currencies; for
instance, c1 might be dol
CS 170, Spring 2016
Discussion Section
A. Chiesa & U. Vazirani
CS170 Discussion Section 12: 4/13 - 4/16
Reliable Network
Reliable Network is the following problem: We are given two n n matrices, a cost matrix
cij , and a connectivity requirement matrix ri
CS170 Discussion Section 10: 11/2-11/4
Repairing a Flow
In a particular network G = (V, E) whose edges have integer capacities ce , we have already
found the maximum flow f from node s to node t. However, we now find out that one of the
capacity values we
CS 170, Spring 2016
Discussion Section
A. Chiesa & U. Vazirani
CS170 Discussion Section 6: 2/24 - 2/26
MST Practice
Find the minimum spanning tree of the following weighted graph. You may want to try out
both Kruskals and Prims algorithms to verify your a
CS 170, Spring 2016
Discussion Section
A. Chiesa & U. Vazirani
CS170 Discussion Section 4: 2/10 - 2/12
1. Shortest Cycle
Give an algorithm that takes as input an undirected, unweighted graph, and returns the
length of the shortest cycle in the graph (if t
CS 170, Spring 2016
Discussion Section
A. Chiesa & U. Vazirani
CS170 Discussion Section 5: 2/17 - 2/19
1. Minimum Spanning Trees
For each of the following statements, either prove or supply a counterexample. Always assume
G = (V, E) is undirected and conn
CS 170, Spring 2016
Discussion Section
A. Chiesa & U. Vazirani
CS170 Discussion Section 8: 3/9 - 3/11
1
Pig
Pig is a 2-player game played with a 6-sided die. On your turn, you can decide either to roll
the die or to pass. If you roll the die and get a 1,
CS 170, Spring 2016
Discussion Section
A. Chiesa & U. Vazirani
CS170 Discussion Section 7: 3/2 - 3/4
1. Playing with Rocks
You and your friend are playing a game called the Rocks Game. The game starts out with
two piles of rocks: one with m rocks and the
CS170 Discussion Section 14: 4/27-4/29
Falafels Limited
You are the CTO of FL (Falafel Limited). Your company is planning to deploy falafel carts
on Mission Street in San Francisco. You may deploy carts at the intersections of Mission
& 1st, Mission & 2nd
CS 170, Spring 2016
Discussion Section
A. Chiesa & U. Vazirani
CS170 Discussion Section 11: 4/6 - 4/9
Glossary
Shown below are some of the problems that we will refer to in this worksheet. They are all
decision problems i.e. for each one, the problem is t
CS170 Discussion Section 13: 4/20-4/22
Half Rudrata Path
Recall that the Rudrata Path problem (Given a graph (V, E), find a path (no repeated
nodes) of length (number of edges) |V | 1) is NP-complete. The half-Rudrata Path
problem
is the following: Given
CS 170
Algorithms
Spring 2014
Elchanan Mossel
HW 11
Due May 2, 6:00pm
1. (30 pts.)
Reductions redux
So far, all the reductions we have seen prove hardness only under the assumption P = NP. However, reductions can also be used to prove unconditional hardne
CS 170
Algorithms
Spring 2014
E. Mossel
HW 10
Due April 25, 6:00pm
1. (20 pts.) Bounded CLIQUE and Fake Reductions
Consider the CLIQUE problem restricted to graphs in which every vertex has degree at most 3. Call this
problem CLIQUE-3.
(a) Prove that CLIQ
CS 170
Algorithms
Spring 2014
Elchanan Mossel
HW 9
Due April 18th, 6:00pm
1. (10 pts.)
Non-Linear Programming
2
A quadratic programming problem seeks to maximize a quadratic objective function (with terms like 3x1 or
5x1 x2 ) subject to a set of linear co
U.C. Berkeley CS170: Algorithms
Midterm 2
Lecturers: Umesh Vazirani & Christos Papadimitriou
April 1, 2004
Midterm 2
Name:
TA:
Answer all questions. Read them carefully first. Be precise and concise. The number of points indicate the
amount of time (in mi
U.C. Berkeley CS170 : Algorithms, Fall 2014
Professor: Elchanan Mossel
Midterm Mar 20, 2014
Mar 20, 2014
Midterm Mar 20, 2014
Name (if you are using more than one name please write all names):
SID:
Person on Right:
Person on Left:
Answer all questions.
U.C. Berkeley CS170 : Algorithms, Fall 2014
Professor: Elchanan Mossel
Midterm #2
Mar 20, 2014
Midterm #2 Solutions
Answer all questions.
Read them carefully rst.
Be precise and concise.
Justify correctness of your answers (except in the T/F questions
CS 170
Algorithms
Spring 2014
E. Mossel
HW 3
Due February 14th, 6:00pm
This homework is due Friday, February 14, at 6:00pm electronically. You need to submit it via Pandagrader.
Please ask on piazza for details on Pandagrader and format. Please turn in al
CS 170
Algorithms
Spring 2014
Elchanan Mossel
HW 2
Due February 7th, 6:00pm
This homework is due Friday, February 7, at 6:00pm electronically. You need to submit it via Pandagrader.
Please see Piazza for details on Pandagrader and formatting. Please turn
CS 170
Algorithms
Spring 2014
Elchanan Mossel
1. (8 pts.)
HW 1
Getting Started
Students receive full credit for writing I understand the course policies under problem 1.
2. (17 pts.)
Compare Growth Rates
(a) f = (g); both are polynomials and 3.75 > 2.72
(
CS 170
Algorithms
Spring 2014
E. Mossel
1. (20 pts.)
HW 3
Problem 2.24 (Quicksort)
1. (5 points). In the worst case we always pick A[k] that is the largest element of A. Then, we
only decrease the problem size by 1 and the running time becomes T (n) = T (
CS 170
Algorithms
Spring 2014
E. Mossel
HW 4
Due February 28th, 6:00pm
This homework is due Friday, February 28th, at 6:00pm electronically. You need to submit it via Pandagrader
with your instructional computer account. Please ask on piazza for details o
CS 170
Algorithms
Spring 2014
Elchanan Mossel
HW 6
Due March 14, 6:00pm
1. (15 pts.) A greedy algorithmso to speak
The founder of LinkedIn, the professional networking site, decides to crawl LinkedIns relationship graph
to nd all of the super-schmoozers.
CS 170
Algorithms
Spring 2014
E. Mossel
1. (15 pts.)
HW 4
Reachability from single vertex
Consider any graph G. In the metagraph of G, if there are two (or more) source strongly connected components, then there can never be a vertex which can reach both o
CS 170
Algorithms
Spring 2014
Elchanan Mossel
HW 7
Due April 4 , 6:00pm
1. (15 pts.) Cutting cloth
You are given a rectangular piece of cloth with dimensions X Y , where X and Y are positive integers, and
a list of n products that can be made using the cl