Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS 577 (Epic) Assignment 3 – Greedy Algorithms

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
25-09-2025
Written in
2025/2026

Assignment 3 – Greedy Algorithms Spring 2021 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: Wisc id: 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. Solution: 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. Solution: (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: Zhuo yanXu txu444 Grey algorithmis a short sighted algorithm tying to maximizelocal gainprofit at eachstep It searchforthecurrentoptimalsolution ineach sg and ignore the futuretrend N n n ET willgetvalue 2 0 ht optimalshouldbe 师 100 100 .­pcsc r we usethe longest finished timefirstalgorithm considerjinset hid S an entryset while tf do choose ji withsmallest fi within T I break ties arbitrarilyI addji to S remove ji front end returns thisrequiressortingjobbasedon fi causeOflog This study source was downloaded by from CourseH on :02:54 GMT -05:00 CS 577 (Epic) Assignment 3 – Greedy Algorithms Spring 2021 (c) Prove the correctness and efficiency of your algorithm from part (c). Solution: 3. Kleinberg, Jon. Algorithm Design (p. 190, q. 5) (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: Page 2 of 5 we define scheduleA M inversion lemma 肌schedules withnoinversionsandno idk inehavethesameuterus if we onlyfan onthejobwithsame fi theymustbesequential rearrangetheorderofthen won't charge latent Thm There is an optimalscheme hasno inversionandno idletime if we we exchange argument technique Considerwebeaoptimalschedules If i i Ǜkchange ij we j­.fi have i j j after i wehavenewschemes F点 isthetimei finishedin i isthetime ifinished ins similarforjj weknow hi ÈPKĚputfi諔fi sincewetakeiahead wehave is ii we heli Èktfj点PutfjEF 靠毙熊 以 we repeatthesesteps untilnoinversions 四 consider the road a straightlines withsomepointsknown as houses IN we startfromleftwalk towardsrightuntil encountering firsthouse we set one tower 4 milesrightaway fromthishouse we startfonthe rightbandyofrangeofprevioustower when we encounter anotherhouse werepeato we repeat nil allthe horses are covered This study source was downloaded by from CourseH on :02:54 GMT -05:00 CS 577 (Epic) Assignment 3 – Greedy Algorithms Spring 2021 (b) Prove the correctness of your algorithm. Solution: 4. Kleinberg, Jon. Algorithm Design (p. 197, q. 18) Your friends are planning to drive north from Madison to the town of Superior, Wisconsin over winter break. They have drawn a directed graph with nodes representing potential stops and edges representing the roads between them. They have also found a weather forecasting site that can accurately predict how long it will take to traverse one of the edges on their graph, given the starting time t. This is important because some of the roads on their graph are affected strongly by the seasons and by extreme weather. It’s guaranteed that it never takes negative time to traverse an edge, and that you can never arrive earlier by starting later. (a) Design an algorithm your friends can use to plot the quickest route. You may assume that they start at time t = 0, and that the predictions made by the weather forecasting site are accurate. Solution: Page 3 of 5 we we5 in iz in denotethesetoftowersfunlefttoright fi Li

Show more Read less
Institution
Assingment
Course
Assingment

Content preview

CS 577 (Epic) Assignment 3 – Greedy Algorithms Spring 2021


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/

Written for

Institution
Assingment
Course
Assingment

Document information

Uploaded on
September 25, 2025
Number of pages
5
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Abbyy01 Exam Questions
Follow You need to be logged in order to follow users or courses
Sold
96
Member since
4 year
Number of followers
33
Documents
1337
Last sold
5 days ago

3.5

13 reviews

5
5
4
2
3
3
2
1
1
2

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions