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
5.3 Horn formulas
In order to display human-level intelligence, a computer must be able to perform at least some
modicum of logical reasoning. Horn formulas are a particular framework for doing this, for
expressing logical facts and deriving conclusions.
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 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 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 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
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 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
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
Exercises
3.1. Perform a depth-first search on the following graph; whenever theres a choice of vertices, pick
the one that is alphabetically first. Classify each edge as a tree edge or back edge, and give the
pre and post number of each vertex.
A
B
C
D
E
Figure 8.9 S is a vertex cover if and only if V S is an independent set.
S
It is easy to see that in the new formula no variable appears more than three times
(and in fact, no literal appears more than twice). Furthermore, the extra clauses involving x1 ,
Chapter 2
Divide-and-conquer algorithms
The divide-and-conquer strategy solves a problem by:
1. Breaking it into subproblems that are themselves smaller instances of the same type of
problem
2. Recursively solving these subproblems
3. Appropriately combin
Figure 7.5 An illustration of the max-flow algorithm. (a) A toy network. (b) The first path
chosen. (c) The second path chosen. (d) The final flow. (e) We could have chosen this path first.
(f) In which case, we would have to allow this second path.
(a)
(
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, 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
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
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
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
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
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
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
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