Professional Documents
Culture Documents
Foundation of Algorithms Assignment 5: Chinmay Kulkarni (ck1166)
Foundation of Algorithms Assignment 5: Chinmay Kulkarni (ck1166)
Assignment 5
Chinmay Kulkarni (ck1166)
2.
if we take z as source:
-2
3. Suppose the activities are S<a1, a2, a3, a4. an > and there start time
finish time are given as follows ai = [ si , fi). Now, we want to start from last
activity, which is compatible with all previous activities, so we will start from
the opposite direction of the set. That is,
Now finish time will be considered over start time and hence ai = [fi, , si ). We
can apply the same greedy approach on activities, according to finish time
until when it starts. Basically the greedy approach will work in reverse
direction.
Therefore, it will have same running time and optimal solution to the
problem.
4.
|--1---|
|-------2----------|
|--------3--------|
|---1---|
|--2--|
|---3---|
|--4--|
|--5--|
|--6--|
|--7--|
|---8---|
|---9---|
5. let there be n knapsacks, k<k1, k2, k3. kn> with value and weight given
as ki =[vi, wi]. now our job is to maximize the fraction of weight from
knapsack to reach threshold limit of weight.
We choose the highest value by weight of any knapsack until the knapsack is
emptied out , and then we choose the next highest value by weight of other
knapsack and then repeat it. So our main aim is to choose next highest value
by weight of knapsack, which is what a greedy algorithm does.
Therefore, fractional knapsack is greedy-choice property.