























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Greedy algorithms and their advantages over other algorithmic approaches. It also provides a formalized algorithm for finding the furthest lilypad and proves that the greedy algorithm always finds a path from the start lilypad to the destination lilypad. The document also includes a theorem that proves the optimality of the greedy algorithm. Additionally, it introduces the concept of a 'greedy stays ahead' proof and applies it to the activity scheduling problem.
Typology: Lecture notes
1 / 31
This page cannot be seen from the preview
Don't miss anything!
























●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
Lemma 1: The greedy algorithm always finds a path from the start lilypad to the destination lilypad. Proof: By contradiction; suppose it did not. Let the positions of the lilypads be x ₁ < x ₂ < … < xₘ. Since our algorithm didn't find a path, it must have stopped at some lilypad xₖ and not been able to jump to a future lilypad. In particular, this means it could not jump to lilypad k + 1, so xₖ + r < xₖ₊ ₁. Since there is a path from lilypad 1 to the lilypad m , there must be some jump in that path that starts before lilypad k + 1 and ends at or after lilypad k + 1. This jump can't be made from lilypad k , so it must have been made from lilypad s for some s < k. But then we have xₛ + r < xₖ + r < xₖ₊ ₁, so this jump is illegal. We have reached a contradiction, so our assumption was wrong and our algorithm always finds a path. ■
●
●
●
●
●
●
Lemma 2: For all 0 ≤ i ≤ | J* |, we have p ( i , J ) ≥ p ( i , J* ). Proof: By induction. As a base case, if i = 0, then p (0, J ) = 0 ≥ 0 = p (0, J* ) since the frog hasn't moved. For the inductive step, assume that the claim holds for some 0 ≤ i < | J* |. We will prove the claim holds for i + 1 by considering two cases: Case 1: p ( i , J ) ≥ p ( i + 1, J* ). Since each jump moves forward, we have p ( i + 1, J ) ≥ p ( i , J ), so we have p ( i + 1, J ) ≥ p ( i + 1, J* ). Case 2: p ( i , J ) < p ( i + 1, J* ). Each jump is of size at most r , so p ( i + 1, J* ) ≤ p ( i , J* ) + r. By our IH, we know p ( i , J ) ≥ p ( i , J ), so p ( i + 1, _J_ ) ≤ p ( i , J ) + r. Therefore, the greedy algorithm can jump to position at least p ( i + 1, J* ). Therefore, p ( i + 1, J ) ≥ p ( i + 1, J* ). So p ( i + 1, J ) ≥ p ( i + 1, J *), completing the induction. ■
●
●
● Find a series of measurements M ₁, M ₂, …, Mₖ you can apply to any solution. ● (^) Show that the greedy algorithm's measures are at least as good as any solution's measures. (This usually involves induction.) ● (^) Prove that because the greedy solution's measures are at least as good as any solution's measures, the greedy solution must be optimal. (This is usually a proof by contradiction.)
Another Problem: Activity Scheduling
●
●
●
●
●
●
●
●