CS 373: Combinatorial Algorithms, Fall 2000
Homework 1 (due November 16, 2000 at midnight)
Name:
Net ID:
Alias:
U
3
/
4
1
Name:
Net ID:
Alias:
U
3
/
4
1
Name:
Net ID:
Alias:
U
3
/
4
1
Starting with Homework 1, homeworks may be done in teams of up to three people. Each team
turns in just one solution, and every member of a team gets the same grade. Since 1-unit graduate
students are required to solve problems that are worth extra credit for other students,
1-unit grad
students may not be on the same team as 3/4-unit grad students or undergraduates.
Neatly print your name(s), NetID(s), and the alias(es) you used for Homework 0 in the boxes
above. Please also tell us whether you are an undergraduate, 3/4-unit grad student, or 1-unit grad
student by circling U,
3
/
4
, or 1, respectively. Staple this sheet to the top of your homework.
Required Problems
1. Give an
O
(
n
2
log
n
)
algorithm to determine whether any three points of a set of
n
points are
collinear. Assume two dimensions and
exact
arithmetic.
2. We are given an array of
n
bits, and we want to determine if it contains two consecutive 1
bits. Obviously, we can check every bit, but is this always necessary?
(a) (4 pts) Show that when
n
mod 3 = 0 or 2, we must examine every bit in the array.
that is, give an adversary strategy that forces any algorithm to examine every bit when
n
= 2
,
3
,
5
,
6
,
8
,
9
, . . .
.
(b) (4 pts) Show that when
n
= 3
k
+1
, we only have to examine
n
−
1
bits. That is, describe
an algorithm that Fnds two consecutive 1s or correctly reports that there are none after
examining at most
n
−
1
bits, when
n
= 1
,
4
,
7
,
10
, . . .
.
(c) (2 pts) How many
n
-bit strings are there with two consecutive ones? ±or which n is this
number even or odd?