COMP 251 Autumn 2013
Solutions to Assignment 4
Gheorghe Comanici
Prakash Panangaden
Question 1
[20 points]
This problem is solved using a greedy algorithm, building the solution from
east to west. We start with a list of all the houses.
•
Find the westmost house, and place a base station 4 miles to its
east
.
•
Remove all the houses covered by this station from the list of houses.
•
Repeat the process until the problem has no more houses.
Does our solution stay ahead of other solutions? Suppose somebody claims
that some other solution
S
=
{
s
1
,s
2
,...,s
k
}
is a better than our solution
T
=
{
t
1
,t
2
,...,t
r
}
(where the stations are sorted from west to east). That
is,
k <r
and both
S
and
T
cover all houses.
•
Note that both
s
1
and
t
1
have to cover the westmost house
h
, but we
chose
t
1
as the east most point to cover
h
, therefore
t
1
≥
s
1
•
Assume
t
i
≥
s
i
.
Then it must be the case that all houses covered
{
s
1
,s
2
,...,s
i
}
will also be covered by
{
t
1
,t
2
,...,t
i
}
, so if we add
s
i
+1
to
{
t
1
,t
2
,...,t
i
}
there won’t be any houses uncovered between
t
i
and
s
i
+1
. But we choose
t
i
+1
as large as possible to cover these houses, so
it must be the case that
t
i
+1
≥
s
i
+1
.
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
 
 Graph Theory, Greedy algorithm, Spanning tree

Click to edit the document details