Answer the questions in the boxes provided on the question sheets. If you run out of room
for an answer, add a page to the end of the document.
Name: Zhuo
yan Xu
Wisc id: txu444
Greedy Algorithms
1. In one or two sentences, describe what a greedy algorithm is. Your definition should be informal,
something you could share with a non computer scientist.
sighted algorithm tying to
short maximizelocal
Grey algorithm is a
Solution:
search the currentoptimalsolution in each and
step It sg
each
gainprofit at for
ignore the future
trend
2. There are many different problems all described as “scheduling” problems. In the following questions,
pay attention to the details of the problem setup, as they will change each time!
(a) Let each job have a start time, an end time, and a value. We want to schedule as much value
of non-conflicting jobs as possible. Use a counterexample to show that Earliest Finish First (the
greedy algorithm we used for jobs with all equal value) does NOT work in this case.
2
ET willgetvalue
Solution:
N 0 n n shouldbe
ht optimal
师 100 100
(b) Kleinberg, Jon. Algorithm Design (p. 191, q. 7) Now let each job consist of two durations. A
job i must be preprocessed for pi time on a supercomputer, and then finished for fi time on a
standard PC. There are enough PCs available to run all jobs at the same time, but there is only one
supercomputer (which can only run a single job at a time). The completion time of a schedule is
defined as the earliest time when all jobs are done running on both the supercomputer and the PCs.
Give a polynomial time algorithm that finds a schedule with the earliest completion time possible.
Solution:
pi.fi pc
sc r
ljij.fr
jin set
consider
we usethe longest finished time firstalgorithm
hid S an entryset
while dotf
withsmallest within T I
break ties arbitrarily I
choose
ji fi
add to S remove ji front
end
ji
returns this requiressortingjobbased on fi cause Oflog
This study source was downloaded by 100000899610689 from CourseHero.com on 09-25-2025 01:02:54 GMT -05:00
https://www.coursehero.com/file/196289218/hw3pdf/
, CS 577 (Epic) Assignment 3 – Greedy Algorithms Spring 2021
(c) Prove the correctness and efficiency of your algorithm from part (c).
we define schedule A
fibfejhtfic.fi
M
Solution: inversion
肌 schedules with no inversionsand no idk ine thesameuterus
have
lemma
we onlyfan on thejob withsame fi theymust besequential
if
rearrangethe orderofthen
won't charge latent
scheme has no inversionand no idletime
Th m There is an optimal
we we exchange argument technique we be Consider aoptimalschedules
if
If i hasinvasionweknowthereis atleastonepair jobs of i.j.withiafterj.fi
i
Ǜk
definep
change
inthe
ij
time
we
all
j have i
jobsfinished.ie
F
have
j after i we new.fi
点pi.li isthetime i in
schemes
finished
hi ÈPKtfi.liĚputfi諔 fi
supercomputer
i isthetime i in s similarfor jj we
finished know
sincewe take i wehave is
ahead ii
以
we heli Èktfj⼆ 点PutfjEFktfiaisinufi.fi 靠
⼗
毙熊
3. Kleinberg, Jon. Algorithm Design (p. 190, q. 5) we repeatthesesteps untilno inversions 四
(a) Consider a long, straight road with houses scattered along it. We want to place cell phone towers
along the road so that every house is within four miles of at least one tower. Give an efficient
algorithm that achieves this goal using the minimum possible number of towers.
Solution: consider the road a straight lines with some points known
as houses
IN
we house
we startfromleftwalk towardsright until encountering first
milesright thishouse
set one tower 4 away from when we
the right bandy range ofprevioustower
we start
fon of
encounter another house werepeat o
d.eu nil all the horses are
covered
we repeat
Page 2 of 5
This study source was downloaded by 100000899610689 from CourseHero.com on 09-25-2025 01:02:54 GMT -05:00
https://www.coursehero.com/file/196289218/hw3pdf/