- Interval Scheduling: Greedy Algorithm Greedy algorithm. allocate d labels(d = depth) sort the intervals by starting time: I 1,I 2,..,I n forj = 1 to n for each interval I i that precedes and overlaps with I j exclude its label for I j pick a remaining label for I j
- Example Make a change for 2.89 (289 cents) here n = 2.89 and the solution contains 2 dollars, 3 quarters, 1 dime and 4 pennies. The algorithm is greedy because at ...
- Greedy Algorithm for Egyptian Fraction The greedy algorithm was developed by Fibonacci and states to extract the largest unit fraction first. Now for a fraction, $\frac{m}{n}$, the largest unit fraction we can extract is $\frac{1}{\lceil\frac{n}{m}\rceil}$.
- There are tons of tasks where greedy algorithms fail, but the best in my opinion is the change-making problem. It is great, because whether the obvious greedy algorithm works depends on the input (i.e. the denominations). For example, if you have coins $1,6,8$, then $12=6+6$ is better than $12=8+1+1+1+1$. Some other tasks:
- Greedy Algorithm - to find maximum value for problem P: tempP = P -- tempP is the remaining subproblem while tempP not empty loop in subproblem tempP, decide greedy choice C Add value of C to solution tempP := subproblem tempP reduced based on choice C end loop