COT5405 exam 2 solution
1.
a)
TRUE
b)
FALSE
Consider the following input: I = [2, 1, 1] and L = 3,
GREEDY(I) =
21
k=0
1
k=2
max(k) = 2
OPT(I) =
2
k=1
11
k=1
max(k) = 1
c)
FALSE
This algorithm does not
COT5405: ANALYSIS OF ALGORITHMS
Exam I
Date: Sept 30, 2015, Thursday
Time: 8:20 pm - 10:10 pm (110 minutes)
or (Oce CSE 534)
Professor: Alper Ung
This is a closed book exam. No collaborations are all
1. [30 points] TRUE/FALSE. No need for justication.
(a)
(b)
(C)
1"
/FALsn .
L G = [ME] be a flow network with source 5 E V and sink 1; E V, and non-negative
egge capacities. If the maximum ow assign
3. [15 points = 8 + 7] AMORTIZED ANALYSIS L1!
Recall the amortized analysis of a sequence of'n insertions into a dynamic tables whose
capacity is doubled every time it becomes full. We used three diff
2. [10 points : 5+ 51 SUPPORTING YOUR CLAIM
Pick any TWO of the statements in Question 1'(a)-(i) that you decided to be FALSE. Give
a complete proof of your decision.
l l
1(5) W 09491;, k too, a We!
"
Solutions
January 27, 2016
Question1:
T (n) = n2 (1 + 5/16 + (5/16)2 + (5/16)3 + + (5/16)n1 )
= (n2 )
T (n) = 2i T (
n
n
n
n
) + n lg n + n lg + n lg . . . n lg i1 = n T (1) + n
2i
2
4
2
lg n1
lg
i=0
Leftist Trees
Linked binary tree.
Can do everything a heap can do and in the
same asymptotic complexity.
insert
remove min (or max)
initialize
Can meld two leftist tree priority queues in
O(log n)
Chapter 3
With Question/Answer Animations
Chapter Summary
Algorithms
Example Algorithms
Algorithmic Paradigms
Growth of Functions
Big-O and other Notation
Complexity of Algorithms
Section 3.1
Se
Solutions
February 15, 2016
Question1:
1.
T (n) =
lg n
X
n
i=0
= (n lg n)
T (n) =
lg n
X
(3/4)i n
i=0
= (n)
2. TRUE, TRUE, FALSE.
3. The recurrence relation is T (n) = 2 T (n/2) + O(n). The worst-case
COT5405 Homework 2 -spring 2016
Assigned: 02/16, Tue
Due: 02/23, Tue
There are five questions for homework 2. Here are the first two questions, and remaining three
will be posted on 02/17 morning.
1.
(s)
(h)
(j)
T /FALsn
(ions or a directed graph G = (V, E) and a source node 3 E V and a weight function
w : E > R. Suppose there exists some edges [5,11] 6 E sourced at s such that their
weight is n
(e) Find a minimum cfw_31,52,537cfw_t1,t2 cut in this network. What is the capacity of this
minimum out?
(f) Starting with a zero flow consider a sequence of three augmentations: (i) < s, s , o, d,t2,
1. [20 points : 4+4+4+4+41Tnoanarse QUESTIONS (no user: nos JUSTIFICATION)
(a) TRUE/FALSE
Bellman-Ford algorithm presented in class for computing shorthest paths is a dynamic
programming algorithm.
Fa
l.(20 points)You are given a family ofS ofm sets S,- , 1g 1' g m. Denote by lAl the size of
set A. Let l Si| =1, i.e., SJ :cfw_Sl=52="'=sj.' Asubset T:cfw_T1,T2,-~,Tk ofSis afamily of
sets such thatfo
Lifi
COWUBOW.
(46) .' Q N ' / ber!
. ~ ' am mgr-Mal "mm .
A each Maid m G 0"; 6
4. [20:10+10 points] MINIMUM SPANNING TREES / SHORTEST PATHS
Given two graphs G and G that have the same sets of v
COT5405 Analysis of Algorithms
Summer 2003
Midterm 3 (07/28/03)
This is closed notes/book inclass exam. Electronic calculators are allowed.
You are expected to derive the best possible algorithm to so
COT 5405 Midterm 2 Solutions
April 1, 2009
1 Problem 4 Graded by Hale
GEOMETRIC DATA STRUCTURES AND ALGORITHMS [30 : 7+ 8+ 7+8 Points]
You may assume that no three points are colinear in the following
. [30 points : 4 + 4 + 6 + 4 + 4 + 8] FLOW NETWORK WITH MULTIPLE SOURCES/5mm
Consider a variant of the Flow Network problem where we have multiple sources and multiple
sinks. Figure shows a ow network
5. [15 points] UNIQUENESS OF SHORTES'I PATHS
a.
Shortest: paths in a graph are not always unique: sometimes there are two or more dierent
paths with the same minimum possible length. ' Given an un
3. [20 points = 10 + 10] AMORTIZBD ANALYSIS
Recall the amortized analysis of a sequence of n. insertions into a dynamic tables whose
capacity is doubled every time it becomes full. We used three diere
Homework 2 solutions
1. Candidate Greedy Strategy I: Take the weakest two oxen, if together they meet the strength
requirement, make them a team. Recursively find the most teams among the remaining
ox
4.8
Huffman Codes
These lecture slides are supplied by Mathijs de Weerd
Data Compression
Q. Given a text that uses 32 symbols (26 different letters,
space, and some punctuation characters), how can we
COT5405 Homework 2 - spring 2016
Assigned: 02/16, Tue
Due: 02/23, Tue
There are five questions for homework 2.
1. Oxen Pairing
Consider the following problem: We have n oxen, OX1, , OXn, each with a s