This preview shows pages 1–2. Sign up to view the full content.
CS 573
Homework 4 (due November 1, 2010)
Fall 2010
CS 573: Graduate Algorithms, Fall 2010
Homework 4
Due Monday, November 1, 2010 at 5pm
(in the homework drop boxes in the basement of Siebel)
1. Consider an
n
node treap
T
. As in the lecture notes, we identify nodes in
T
by the ranks of their
search keys. Thus, ‘node 5’ means the node with the 5th smallest search key. Let
i
,
j
,
k
be integers
such that 1
≤
i
≤
j
≤
k
≤
n
.
(a) What is the
exact
probability that node
j
is a common ancestor of node
i
and node
k
?
(b) What is the
exact
expected length of the unique path from node
i
to node
k
in
T
?
2. Let
M
[
1..
n
,1.
.
n
]
be an
n
×
n
matrix in which every row and every column is sorted. Such an
array is called
totally monotone
. No two elements of
M
are equal.
(a) Describe and analyze an algorithm to solve the following problem in
O
(
n
)
time: Given indices
i
,
j
,
i
0
,
j
0
as input, compute the number of elements of
M
smaller than
M
[
i
,
j
]
and larger
than
M
[
i
0
,
j
0
]
.
(b) Describe and analyze an algorithm to solve the following problem in
O
(
n
)
time: Given
indices
i
,
j
,
i
0
,
j
0
as input, return an element of
M
chosen uniformly at random from the
elements smaller than
M
[
i
,
j
]
and larger than
M
[
i
0
,
j
0
]
. Assume the requested range is
always nonempty.
(c) Describe and analyze a randomized algorithm to compute the median element of
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '08
 Chekuri,C
 Algorithms

Click to edit the document details