Posts

Image
  Greedy algorithms Any algorithm that follows the problem-solving heuristic of choosing the locally best option at each stage is known as a greedy algorithm.  A greedy strategy may not produce an optimal solution in many cases, but it can produce locally optimal solutions that approximate a globally optimal solution in an acceptable amount of time. As the name implies, a greedy algorithm always chooses the option that appears to be the best at the time. This means it will make a locally optimal decision in the hopes of arriving at a globally optimal answer. For example, a greedy strategy for the travelling salesman problem (which has a high computing cost) is to "visit the nearest unvisited city at each step of the route. This heuristic does not aim to discover the best answer, but it does it in a fair number of steps; finding the best solution to such a difficult problem usually takes an unreasonable amount of time. Greedy methods are used in mathematical optimization to