• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 5 páginas
Examen

CS 577 (Epic) Assignment 3 – Greedy Algorithms

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

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

Vista previa del contenido

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/

Información del documento

Subido en
25 de septiembre de 2025
Número de páginas
5
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$10.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Abbyy01
3.5
(13)
Vendido
98
Seguidores
33
Artículos
1332
Última venta
3 meses hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes