Greedy Method
Greedy Method
Greedy Choice Property: At each step, the algorithm makes the choice that
appears to be the best option at that moment. This choice is often based on a
heuristic or a set of rules that consider the current state of the problem.
Optimal Substructure: A problem exhibits optimal substructure if an optimal
solution to the overall problem can be constructed from optimal solutions to its
smaller subproblems. Greedy algorithms typically work well when the problem
can be broken down into smaller, independent subproblems.
Lack of Backtracking: Unlike some other algorithms, greedy algorithms do not
backtrack or reconsider previous choices. Once a decision is made, it is never
revised.
Efficiency: Greedy algorithms are often efficient and can provide near-optimal
solutions in a relatively short amount of time. However, their solutions are not
always guaranteed to be globally optimal.
Greedy algorithms are applied to a wide range of problems, including:
Finding the minimum spanning tree in a graph (Kruskal's and Prim's algorithms).
Solving the fractional knapsack problem.
Huffman coding for data compression.
Shortest path problems in a graph (Dijkstra's algorithm).
Job scheduling and task allocation problems