17191114161513
M 11I
db db
B Dali
I 154161513
Di Dt
1K
DX
Dat b
tf k
d ITE
Is
L
K tf
6
I
2
Divide
4s
6 7
3
Conger
Combine
equation for Tcu
recurrence
Conquer
1n 2tnz
x Divide
OCn ¦Ìiz.TV
i Combine
Cn
OCi
z
OG
2 Tcnk Ocn
Cn size
on
1
arrayof
merge sort ifn
piidettime siphroblend OO
sized
each subproblem
I combintime
Ten
on
Tcnk
Cn
7144
TCnly Cn
11 TCnly
Take11
Cn
waqf
CCCC
overall art 0
nGu
Tak
c
on
nbs9bte.uwgg.n pTfcn.enhggnwg9b.n
mini’s.ee
fan
This falls into Tca
z nlg2n
nwg9b
Casey ffeu
n.no
z
nw99b
n
Casey
fin
n’tg
ri ni
diff
an E0
000001
a
fab
Topheavy
nib
qq.org.eg
bottom beam
ng
Tau
ofsubproblem
1 8
X
n
lasteenel
at level xx2A
x
e
n 3 AZ tabs
complenityotyesnt
Iga
Yod
n
fuk
j
Case 2 Tcn7 04Gn
en Samerate
Brute
i
TT u
2
ii Cn foreet
dnt
Sellin B
Min M Ma
Casca B Bt
IEEE
Bay
reset
Buy S
M
X Max X Xz
S’s Casca
Skip
BB
qq.in
S
Sz
Stock MarketProblem
T.pe
t.hr
Soe
Si
P
Xi
PZ
Sz
Xz
I
MI logg logs
n
nbn
2
Fon
04
case I Tcn n
nlaffGB
7
a C 12
Aiz.B Aiz.B
amnesia
OGI
Bruteforce approach fi
t
A
OGI EtEt
A E
fca alogg
D n t Ccn
box nbg
CUZ I
Olof case I
n3
Tca
EH Tcu
Ca psT 92 RtT
N
C21 C 22
QS Pt R
U fabfafinmttjdia.tw
Q Strassen’s Method
forL c I Tca1 0455 nagas nut nasty case
Bunte force Mz
Finding Min Max in an unsortedarray
o
Cnt enl 3
I
o ll
l
R R On R n oOO0
closestpairofpoints onazD plane
geminted
EE
p
P
e
t
Bute force Case t
T
n
e
k r
n
1 Cm2t
Ocn 2
cI
Ca
Booth pt’s are in
case2 c nn nept.isinfatheothuil
P il
i
84.74
821
28
iii
l
Conquer 0
0th
f
2541044 case
A
can
problem
bedone in Cuba
C A
B
Voronoi
Diagram
Discussion 5
1. Suppose we have two graphs G1 = (V1, E1) and G2 = (V2, E2), along with T1 which is a MST of G1 and T2 which is a MST of G2. Now consider a new graph G = (V, E) such that V = V1 U V2 andE=E1 UE2 UE3 whereE3 isanewsetofedgesthatallcrossthecut(V1,V2).
Consider the following algorithm, which is intended to find a MST of G.
Does this algorithm correctly find a MST of G? Either prove it does or prove it does not.
2. Solve the following recurrences using the Master Method:
a. A(n) = 3 A(n/3) + 15
b. B(n) = 4 B(n/2) + n3
c. C(n) = 4 C(n/2) + n2
d. D(n)=4D(n/2)+n
3. There are 2 sorted arrays A and B of size n each. Design a D&C algorithm to find the median of the array obtained after merging the above 2 arrays (i.e. array of length 2n). Discuss its runtime complexity.
4. A tromino is a figure composed of three 1×1 squares in the shape of an L. Given a 2nx2n checkerboard with 1 missing square, tile it with trominoes. Design a D&C algorithm and discuss its runtime complexity.
011
is.is iDFEIocnifCn1
fca
15
n3nY9 nhgI
Cfca aus
By Levi
s
afalb 41 13
neJoase
c
5
CC n
fca k
4C
Va
hogg n
ist
Case 2 Tca
1n OTn3
cn 4Enk
n n
th2lgk fca
deai
I t.am
n24k
d
riya
oGTfiil
Tca
Tng 2TChlo
Discussion 3
1. Let’s consider a long, quiet country road with houses scattered very sparsely along it. We can picture the road as a long line segment, with an eastern endpoint and a western endpoint. Further, let’s suppose that, despite the bucolic setting, the residents of all these houses are avid cell phone users. You want to place cell phone base stations at certain points along the road, so that every house is within four miles of one of the base stations.
Give an efficient algorithm that achieves this goal and uses as few base stations as possible. Prove that your algorithm correctly minimizes the number of base stations.
2. Your friend is working as a camp counselor, and he is in charge of organizing activities for a set of campers. One of his plans is the following mini-triathlon exercise: each contestant must swim 20 laps of a pool, then bike 10 miles, then run 3 miles. The plan is to send the contestants out in a staggered fashion, via the following rule: the contestants must use the pool one at a time. In other words, first one contestant swims the 20 laps, gets out, and starts biking. As soon as this first person is out of the pool, a second contestant begins swimming the 20 laps; as soon as he or she is out and starts biking, a third contestant begins swimming, and so on.
Each contestant has a projected swimming time, a projected biking time, and a projected running time. Your friend wants to decide on a schedule for the triathlon: an order in which to sequence the starts of the contestants. Let’s say that the completion time of a schedule is the earliest time at which all contestants will be finished with all three legs of the triathlon, assuming the time projections are accurate.
What is the best order for sending people out, if one wants the whole competition to be over as soon as possible? More precisely, give an efficient algorithm that produces a schedule whose completion time is as small as possible. Prove that your algorithm achieves this.
3. The values 1, 2, 3, . . . , 63 are all inserted (in any order) into an initially empty min-heap. What is the smallest number that could be a leaf node?
4. Given an unsorted array of size n. Devise a heap-based algorithm that finds the k-th largest element in the array. What is its runtime complexity?
5. Suppose you have two min-heaps, A and B, with a total of n elements between them. You want to discover if A and B have a key in common. Give a solution to this problem that takes time O(n log n) and explain why it is correct. Give a brief explanation for why your algorithm has the required running time. For this problem, do not use the fact that heaps are implemented as arrays; treat them as abstract data types.