1. Write Control abstraction for greedy method by using subset paradigm?
Ans .
Terminologies are used in subset paradigm: feasible solution,
objective function, optimal solution
feasible solution: Any subset that satisfies these constraints is called feasible solution
objective function:to find a feasible solution that either maximizes or minimizes a given objective function.
optimal solution:A feasible solution that does this is called an optimal solution.
Greedy method control abstraction for the subset paradigm
SolType Greedy(Type a[], int n)
// a[1:n] contains the n inputs.
{
SolType solution = EMPTY; // Initialize the solution
for (int i = 1; i <= n; i++) {
Type x = Select(a);
if Feasible(solution, x)
solution = Union(solution, x);
}
return solution;
}
Subscribe to:
Post Comments (Atom)
4 comments:
thanqqq helped me a lot in correct time
thanxx a lot,very good explanation
thanxx a lot,very good explanation
Thanks a lot, i was searching for an explanation of how to prove the optimality of the greedy knapsack problem, finally i landed on your blog. thanks a lot for sharing your knowledge with others.
thanks a lot.
i will be very grateful to you ever.
Post a Comment