CS 473: Fundamental Algorithms, Spring 2012
Homework 4 (due Tuesday, 23:55:00, February 21, 2012)
See homework 1.
Each student individually have to also do
quiz 4
online.
Version:
1.2
1. (
30 pts.
)
Counting signiﬁcant inversions.
Let
a
1
,a
2
,...,a
n
be a sequence of
n
integers. A pair (
i,j
) with 1
≤
i < j
≤
n
is said to be an
inversion
if
a
i
> a
j
. Given a sequence suppose we wish to ﬁnd the total number of inversions
in the sequence. There is an
O
(
n
log
n
) time algorithm based on divideandconquer for this
problem (see KleinbergTardos Section 5.3 if you cannot ﬁgure this out). Consider variant
of the problem where we say that pair (
i,j
) with 1
≤
i < j
≤
n
is an
important
inversion if
a
i
>
10
a
j
. Describe an
O
(
n
log
n
) time algorithm for counting the important inversions in a
given sequence.
2. (
35 pts.
)
Planning road trip.
You are going on a long trip. You start on the road at mile post 0. Along the way there are
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.
 Spring '08
 Chekuri,C
 Algorithms, Optimization, Greedy algorithm, Penalty

Click to edit the document details