0% found this document useful (0 votes)
67 views2 pages

Exercises: Greedy Algorithms: Licen Ca Creative Commons

This document contains two questions as exercises for a theory of computation and algorithms class. Question 1 involves finding an efficient algorithm to maximize expected earnings from answering questions in a quiz where the probability of answering each question correctly decreases. Question 2 involves finding a task order for a carpenter to maximize total payments from clients, where earlier task completion means higher payment that doubles for each day earlier. The document provides examples and rules for submitting exercise solutions.

Uploaded by

Guilherme Korol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views2 pages

Exercises: Greedy Algorithms: Licen Ca Creative Commons

This document contains two questions as exercises for a theory of computation and algorithms class. Question 1 involves finding an efficient algorithm to maximize expected earnings from answering questions in a quiz where the probability of answering each question correctly decreases. Question 2 involves finding a task order for a carpenter to maximize total payments from clients, where earlier task completion means higher payment that doubles for each day earlier. The document provides examples and rules for submitting exercise solutions.

Uploaded by

Guilherme Korol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Universidade Federal do Rio Grande do Sul CMP601 – Teoria da Computação e Algoritmos

Instituto de Informática 2020/1


Departamento de Informática Teórica Profs. Álvaro Freitas Moreira, Marcus Ritt

Exercises: Greedy algorithms


Question 1 (The show, 2.5 pt)
Your are in a question-and-answer show and have to answer n questions. If you answer
question i ∈ [n] correctly, you get a prize of di dollars. You can answer the questions in
any order you like. There’s a catch however: the quiz ends with the first question you
answer incorrectly. Looking at the questions, you see that your probability of answering
question i ∈ [n] correctly is pi . Find an efficient algorithm that maximizes the expected
total value you win.
Example: Let n = 4 and probabilities and prizes as follows
i 1 2 3 4
di 3 1 4 1
pi 0.5 0.9 0.2 0.6
If you answer the question in the order given, your expected reward is

p1 (1 − p2 )d1 + p1 p2 (1 − p3 )(d1 + d2 ) + p1 p2 p3 (1 − p4 )(d1 + d2 + d3 )


+ p1 p2 p3 p4 (d1 + d2 + d3 + d4 )
= 0.05 · 3 + 0.36 · 4 + 0.036 · 8 + 0.054 · 9 = 2.364.

Question 2 (A carpenter, 2.5 pt)


A carpenter has to execute n tasks for different n clients, and each task j ∈ [n] takes
time pj . He can execute only a single task at a time, and once having started with a
task, he has to finish it, so he is not able to switch between tasks. Therefore, P he will
start at time 0, execute the tasks in some order, and then finish at time P = j∈[n] pj .
The clients are very interested in getting their tasks done first. So they’re willing to pay
exponentially more, if they get their task finished earlier. Concretely, if task j completes
at time Cj , then client j is willing to pay wj 2P −Cj for some base rate wj . In other words,
for every day the task finishes earlier, the payment doubles. Help the carpenter finding
the task order such that the total payments j∈[n] wj 2P −Cj are maximized.
P

Example: Let n = 4 and times and base rates as follows


j 1 2 3 4
pj 3 1 4 1
wj 5 9 2 6
If you execute the tasks in the order given, the completion times and payments will be
j 1 2 3 4
Cj 3 4 8 9
Pay 5 · 26 9 · 24 2 · 21 6 · 20
so you receive a total value of 474 dollars.

Due date: May 19th, 2020.

v7316 1 Licença Creative Commons


(Atribuição-Uso Não-Comercial-Não a obras derivadas 2.5 Brasil)
Universidade Federal do Rio Grande do Sul CMP601 – Teoria da Computação e Algoritmos
Instituto de Informática 2020/1
Departamento de Informática Teórica Profs. Álvaro Freitas Moreira, Marcus Ritt

Rules for exercise lists


1. The exercises can be solved in collaboration with colleagues, but must be turned
in individually, informing the names of possible collaborators.

2. Exercises are expected in PDF, not written by hand.

3. To gain points the answers must be justified (i.e. proved): a reponse consists of
an algorithmic idea, a correctness proof and a complexity analysis. The points
you get depend on the correctness of the statement, and in case of algorithms the
complexity of the algorithm. You get points for every correct solution, but more
efficient solutions get more points.

4. Only turn in answers you are able to explain on demand.

v7316 2 Licença Creative Commons


(Atribuição-Uso Não-Comercial-Não a obras derivadas 2.5 Brasil)

You might also like