u P n G z u P
scg"R~ c'~s
P l 1 ) j 1 )
R"BHk3d3 (
&" kX6 gidB3d"Ro$sR" "uR6 Hge ) o i) ! k06 vB
! 5 e ! #eP l 1 ! ! lP 6 ! & !P ) ! # ! ! 5 !
) ! P ) 1 e ! ! u u ! 5 e ) ! 6 1 !
i "Bkgv4gC6 [email protected]'gvwscq" kcw6 3vd
e6 vrecsc'd Dscqsc' 6 4 3U R
CS381
Homework 3 Sketch of Solution
Fall 2013
Problem 1. The peak demand for the resource occurs at a time that is covered by the
largest number of intervals, a number that can be computed in O(n log n) time as follows.
1. Initialize a counter variable co
CS381
Homework 7
Fall 2013
Question 1. (20 points) Let S be a set of n two-dimensional points pi = (xi , yi ), 1 i n,
where all the cordinate values are distinct (i.e., no two are equal). Let M (S ) denote the subset
of S that contains every point pi such
CS381
Homework 8
Fall 2013
Question 1. (20 points) Let G be an n-vertex directed graph that has the following
properties:
For every vertex v , the number of other vertices that appear on the adjacency list of
v is exactly the same as the number of times
CS381 Lecture Notes on
Largest Square Block of Ones
Finding a largest square block of 1s in a Boolean matrix
Let A be an n n matrix of 0s and 1s. We seek an O(n2 ) time algorithm for nding the
largest square block of A that contains 1s only. For example,
CS381 Notes on FFT and Convolution
Notation
In what follows wn denotes e2 1/n . The propoerties of wn that we will use are (i)
n1
(wn )n = 1; (ii) (wn )2 = w(n/2) ; and (iii) k=0 (wn )ik is 0 if i = 0 mod n, n if i = 0 mod n.
FFT Algorithm
Input is a an n
CS381
Lecture Notes on Searching in k Arrays
We are given k sorted arrays L1 , . . . , Lk of n elements each, k n. We want to build
a data structure for processing Locate(x) queries: Such a query is supposed to return the
position (i.e., rank) of x in eac
CS381
Lecture Notes on the Pointwise Max of Lines
Computing the pointwise max of n lines
Problem denition
The input is an n-element list L whose ith element describes an ane function fi (x) =
ai x + bi . The ith element of L contains the constants ai and
a
e
i
a
b
f
j
b
c
g
d
h
Articulation point
Bridge
c
e
a
f
e
i
j
c
g
d
h
Biconnected
components
v
u
Low[u]=d[v]
a
e
b
f
j
c
g
d
h
d=1
i
2
3
4
5
6
d
h
3
b
c
a
Low=1
1
8
1
9
7 f 1
10
e
i
j
8
8
8
3
= articulation pt.
g
3
Hw3
Name: Mengxue Luo
PUID: 0027148049
Q1.
/ function check if the number is in range
boolean checkRange(num, low, high)
cfw_
if num >= low and num <= high:
return true;
endif
return false;
/ global variable used to store the sum o
CS381
Homework 6
Fall 2013
Question 1. (30 points) Let P = p1 p2 pm be a string and let f be the function (as
dened in class) such that f (i) is the length of the longest proper prex of p1 p2 pi that
is also a sux of p1 p2 pi . For example, if P = abracad
CS381
Homework 5
Fall 2013
Question 1. (20 points) Suppose that a connected undirected graph G does not contain
a bridge, but that removing any edge from it results in a graph which contains one or more
bridge(s). Assume n 3. Prove that G has no more than
l d 5 2 ) ! #! 1
iRiRfB uuoffptRi6 3& m r 'eu' c 43Ri
r ~ l d 5
7 2 ) ! ) ! dl ) 6 1 ! d P ) ! ! ) ! d % ! 5 d
fB [email protected] BX`s6 [email protected] "06 @s6 D 'H R R @9
& RiR tjD
l d 5 2 ) ! d
~ 6 5 ) l d ! lx l d 5 2 ) ! ~ 6 5 ) l d ! l
gRR 8R6 $& RiRfB tpR6 gRR o8R6 $x
&
i # i ! ! | ! P m 1 i 57 1 P 2 i m ! ! i # v u & h i i # 1 ! i zP )
lc) `vlxp0R"6 6 l93pHtl6 "B! R'2
! v i 1 ! z 5 ! i ! m 1 ) ! ! ! h iP 2 ! P 1 P 2 m ! v i 6 5 ) i I &
6 3v vu# 6 ) epR'RCR"i 36 4Ru
& 1 ! ! z ) m
v jc3
) ! ) z i ! % I i % I & ! z ) m
b
gc p
w yw tp d
s he 2 c p e `9slt
b dd w
6u
y g y p t g g d g t p t y w w y w y
DurvwvEquyv67yec tp e Bp s%w"v69u
t tp t y ptw t w
gtf"jv`ihf6d`wuxrtvu`vEEufkv`Dq`h
t w b d
pt yw ptw t yw q r t w yw g j g w
s
b p c p x` tp 9t
e r
ty
p
q p %
q
CS381
Homework 3
Fall 2013
Question 1. (20 points) Recall that, in the activity-selection problem that we covered
in class, we had a single copy of a resource and the problem was to use it optimally (i.e.,
to satisfy as many of the n requests as possible)
CS381
Homework 1
Fall 2013
Question 1. (20 points) Rank the following functions by increasing order of growth (i.e.,
the slowest-growing rst, the fastest-growing last):
(log log n)2 , log(n!), n, n!, n1.1 , n log n, 2n , n2 , (log n)0.3
where all the loga
CS381
Homework 1 Sketch of Solution
Question 1. (log log n)2 , (log n)0.3 ,
Fall 2013
n, cfw_n log n, log(n!), n1.1 , n2 , 2n , n!
How to gure out log(n!): In such cases it often helps to sandwich the troublesome
function (in this case n!) between two oth
CS381
Homework 2
Fall 2013
Question 1. (25 points) Recall that we covered in class the simultaneous minimum
and maximum problem described in Section 9.1 of the textbook. This question explores a
dierent algorithm for that problem.
1. (10 points) Assuming
CS381
Homework 4
Fall 2013
Question 1. (30 points) Let G be a directed graph whose vertex set is cfw_a, b, c, d, e, f, g, h, i, j, k, l, m, n, o
and whose adjacency lists representation is given below.
L[a]:
L[b]:
L[c]:
L[d]:
L[e]:
L[f]:
L[g]:
L[h]:
L[i]:
Q1:
Physical Data Independence has the ability to modify the physical schema
without changing the logical schema. For example, in case we want to
change or upgrade the storage system itself suppose we want to
replace hard-disks with SSD it should not hav
Hw1
T(n) = aT(n/b) + f(n)
Q1:
a. T(n) = 9T(n/3) + n^2 for n > 2, and T(n) = 1 otherwise.
a = 9, b = 3, f(n) = n^2
since f(n) = Theta(n^(log3 9) = n^2, T(n) = Theta(n^2 * log n) for n > 2
b. T(n) = 6T(n/2) + n^2.4 for n > 1, and T(n) = 1 othe
Purdue University
West Lafayette
CS 381
Mahmood
Hambrusch
Fall 2015
Assignment 6
Due: Tuesday, April 26, 2016 (Submitted to BB before 11:30 pm)
You can make at most 3 upload attempts. Make sure you use the template when writing your answer.
1) (20 pts.)
(
CS 38100
Assignment #2 Solution, Part 1
Due on Thursday, February 11, 2016
CS 38100 TAs
1
CS 38100 TAs
CS 38100 : Assignment #2 Solution, Part 1
CONTENTS
Problem 2 is graded by Samson Zhou
Problem 1 is graded by Wuwei Zhang
Contents
Problem 1
i) . . . .
i
CS 38100
Assignment #3 Solution
Due on Thursday, March 10, 2016
CS 38100 TAs
1
CS 38100 TAs
CS 38100 : Assignment #3 Solution
CONTENTS
Problem 1,2 is graded by Samson Zhou
Problem 3,4 is graded by Wuwei Zhang
Contents
Problem 1
1.1 . . . . . . . . . . . .
CS 381
Fall 2017
MIDTERM 1 - Key only (no explanations included)
Wednesday, September 27, 2017
1. (1 pt) I understand where to put my answers on this 2-sided exam. I have read and understand the
directions on page 1. Answer with a YES in the box below.
2.
Purdue University
CS 381
Hambrusch
Spring 2015
Assignment 3 - Solution Sketches
1) (20 pts.) Review the divide and conquer algorithms discussed in class (see slides posted on 1/29/15). For
problems 1-3 consider the O(n) time divide-and-conquer algorithm n
Purdue University
CS 381
Hambrusch
Spring 2015
Assignment 4 - Solution Sketches
The solutions presented are based on the answers provided by a student in 381.
We thank the student for giving permission to use the solution.
1) (15 pts.) Consider the follow