What is a greedy algorithm?
The greedy:
What is the template for a greedy algorithm?
Input:
Initialization:
step:
End:
What is the template for a mathematical proof of greedy algorithms?
greedy algorithm proof template:
*
How the algorithm(shortest end time) for the activities problem is proved to be correct?
Activities problem S
Legal solution:
Show an algorithm for this problem.
Initialization:
loop: for all i in the sorted S
Activities problem(division)
what is a depth of an instance of the problem?
It is the maximal number of sections which intersect.
Activities problem(division)
Stages in the proof:
Activities problem(division)
Stages in the proof:
The algorithm returns a legal solution with minimum number of sets.
Activities problem(division)
Stages in the proof:
The number of sets the algorithm opens is smaller or equal to the depth of the instance for the problem.
Activities problem(division)
Stages in the proof:
Observation: the algorithm returns a legal solution
Proof:
Activities problem(division)
Stages in the proof:
That means, there are d-1 elements which intersect with i, and because i’s length is positive, there is a point in which all d elements intersects. Thus, the depth is at least d.
Activities problem(division)
How is it implemented:
Activities problem(division)
How is it implemented:
Activities problem(division)
How is it implemented:
Loop:
End:
Heap:
O(log(n))