Midterm Exam
Closed book exam
Cheat sheet: you are allowed 8.5x11 sheet, both
sides
Calculator allowed
8/13/16
1
Topics covered
Analysis
Compare order of growth
Prove asymptotic notation using basic definition
Analyzing non-recursive algorithms
An
Final Review Practice Problems
1) Consider the following code for driving a robot in a spiral-like pattern:
SPIRAL(n):
1. If n _ 1, return (without doing any driving).
2. Drive north n miles.
3. Drive west n miles.
4. Drive south n miles.
5. Drive east n-
Exam 1 Solutions Spring 16:
1. (2 points) If f(n) = O(g(n) and g(n) = O(h(n), then f(n) = O(h(n) True
2. (2 points) If f(n) = O(n2) and g(n) = O(n2), then f(n) = Theta(g(n). False
3. (3 points) If g(n) = 2n and f(n) = 4n which of the following are true. T
CS325 Winter 2013: HW4
Due Feb 22nd in class
1. Knapsack without repetitions. Consider the following knapsack problem:
The total weight limit W = 10 and
Item
1
2
3
4
Weight
6
3
4
2
Value
$30
$14
$16
$9
Solve this problem using the dynamic programming algo
CS 325 - HW 1 Solutions Examples
Problem
Points
1
1
2
NOT GRADED
3
3
4
2
5
3
6
5
7
6
Since some problems have multiple right answers I have compiled some possible correct solutions
submitted by students.
Problem 1: 1 point - must include either a graph, t
CS325 Exam II Winter 2012
3pm - 3:50pm Wednesday, Feb 22nd
Name (First and Last):
(Please print)
1. You have 50 minutes to nish the exam.
2. There are 6 pages in this exam (including cover page), please write down your initials on top of EVERY
page.
3. If
CS325 (Winter 2012) Quiz 5
Your Name (First and Last) :
2/17/2012, Good Luck!
1. (2pts each) Knapsack without repeatition: Given a set of items with weights w1 , ., wn and
values v1 , ., vn , what is the maximum value that we can t in our sack under the w
CS 325 Fall 16
Homework Assignment 1
The following problems are from the 3rd edition of Introduction to Algorithms, CLRS. Attempt to solve
these problems independently and then discuss the solutions in your Homework discussion groups.
Submit a professiona
CS325 Winter 2013: HW3
Due Feb 1st in class
Hand in Instructions Read the guidelines for written assignments on the
course web site. You are highly encouraged to work in groups of up to three.
1. Textbook 4.1
2. Textbook 5.2
3. Textbook 5.5
4. Textbook 5.
CS325 Winter 2013: HW2 - solution
Due Jan 25th in class
Hand in Instructions Read the guidelines for written assignments on the
course web site. You are highly encouraged to work in groups of up to three.
1. Given two sorted arrays a[1, ., n] and b[1, .,
CS 325 Project 3: Linear Programming
For this project, you will model the following problems as linear programs and solve them using a
language/linear programming /mathematical software of your choice (problems may be solved using
different methods) . Inc
CS 325 Midterm Practice Problems
1. (True/False) The running time of a dynamic programming algorithm is always (P) where P is the
number of subproblems.
2. (True/False) If f(n) = O(g(n) and g(n) = O(h(n), then f(n) = O(h(n)
3. Give asymptotic upper and lo
CS325 Exam I Winter 2012
3pm - 3:50pm Wednesday, Feb 1st
Name (First and Last):
(Please print)
1. You have 50 minutes to nish the exam.
2. There are 6 pages in this exam (including cover page), please write down your initials on top of EVERY
page.
3. If y
CS 325 Midterm Practice Problems - Solutions
1. (True/False) The running time of a dynamic programming algorithm is always (P) where P is the
number of subproblems.
2. If f(n) = O(g(n) and g(n) = O(h(n), then f(n) = O(h(n) True
3. Give asymptotic upper an
CS 325 Week 2- Practice Problems
Problem 1: How many times as a function of n (in form), does the following PHP function echo
Print? Write a recurrence and solve it.
function foo( $n ) cfw_
if ($n > 1) cfw_
foo($n/2);
foo($n/2);
foo($n/2);
foo($n/2);
for
Greedy Algorithms
The Greedy Algorithm Techniques
Knapsack Problem
Huffman Codes
Scheduling
1
Scheduling Problems
There are many variations of the scheduling
problem.
Activity: Goal maximize the number of
activities
Machine/Task Scheduling: Goal minimiz
Dynamic programming:
Edit Distance
Edit Distance
Given two strings s and t, the edit distance
between s and t is the minimum number of
editing operations needed to turn s into t
Editing operations
Insertion
Deletion
Substitution
Example
s:
t:
Distan
CISC320 Algorithms Recurrence Relations
Master Theorem and Muster Theorem
Big-O upper bounds on functions defined by a recurrence may be determined from a
big-O bounds on their parts. Here is a key theorem, particularly useful when estimating the
costs of
DP HW Group
1. Rod Cutting
2. Coin Change Problem:
Solution is Project 2
DP HW Group
3. Longest Palindrome Subsequence
DP HW Group
DP HW Group
DP HW Group
CS 325 Midterm Practice Problems
1. (True/False) The running time of a dynamic programming algorithm is always (P) where P is the
number of subproblems.
2. (True/False) If f(n) = O(g(n) and g(n) = O(h(n), then f(n) = O(h(n)
3. Give asymptotic upper and lo
CS325: Analysis of Algorithms, Fall 2016
Group Assignment 2
Due: Tue, 10/25/16
Homework Policy:
1. Students should work on group assignments in groups of preferably three people. Each group submits to
TEACH a zip file that includes their source code and t
CS325: Analysis of Algorithms, Fall 2016
Practice Assignment 3 Solution
Problem 1.
Let Mst be the minimum spanning tree of G.
(a) True. Let (A, V \ A) be a partition of V and e = (u, v) be the minimum-weight edge
that has exactly one endpoint in A. Suppos
CS325: Analysis of Algorithms, Fall 2016
Practice Assignment 2
Due: Tue, 10/18/16
Homework Policy:
1. Students should work on practice assignments individually. Each student submits to TEACH one set of typeset
solutions, and hands in a printed hard copy i
CS325: Analysis of Algorithms, Fall 2016
Group Assignment 1
Due: Tue, 10/11/16
Homework Policy:
1. Students should work on group assignments in groups of preferably three people. Each group submits to
TEACH a zip file that includes their source code and t
Practice questions
Greedy algorithms
1. Prove by contradiction that for any cycle in a graph G whose edges have unique edge weights, the minimum
spanning tree of G excludes the maximum-weight edge in that cycle
Denote the maximum-weight edge in that cycle
Dynamic Programming:
knapsack
Planning for Mars One
Mission
Mars one spaceship has a fixed weight limit
There are a lot of different things to
choose from to bring on board
They each has a weight and a value
How can we maximize the value of the things
Divide and Conquer: Closest Pair of Points
From the book by Kleinberg and Tardos
Adapted from Kleinbergs notes
Problem: Closest Pair of Points
Problem Definition:
Given n points in the plane, find a pair with
smallest Euclidean distance between them.
A fu
Intractability:
Reduction
Adapted from Kevin Waynes slides
Question: which problems will we be able to solve in
practice?
A working definition: those with polynomial runtime
algorithms
Question: suppose we can solve problem Y in poly-time.
What else can w