Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Why Greedy? | Greedy Algorithms: Overview and Examples
Greedy Algorithms using Python
course content

Course Content

Greedy Algorithms using Python

Greedy Algorithms using Python

1. Greedy Algorithms: Overview and Examples
2. Greedy on Arrays
3. Greedy on Graphs

bookWhy Greedy?

Why Greedy?

The aim of the Greedy approach is to reach the optimal solution as fast as possible. It may be optimal in some cases, but we can’t always guarantee that this is the best solution. The greedy search may be faster and simpler than the correct solution, that’s why it is used instead of a more complex one.

The examples are searching optimal paths on graph problems. In The Travelling Salesman Problem, the point is to find the shortest path to connect all the cities, and each city must be visited only once. This problem has no solution, and we can try to apply some greedy approach: for each new city, select the nearest unvisited city, for example. But we can’t prove or guarantee that a found solution will be optimal.

The Dijkstra algorithm from the last chapter reaches the optimal solution, but only for positive-weighted edges, and we can’t guarantee it for negative-weighted edges.

Anyway, the Greedy approach is common-used and applicable, and we’ll solve some problems with it.

Close-packing of equal spheres problem is one of the unsolved problems where the Greedy approach isn’t applicable. There are known solutions only for dimensions of size 1, 2, 3, 8, and 24.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 1
toggle bottom row

bookWhy Greedy?

Why Greedy?

The aim of the Greedy approach is to reach the optimal solution as fast as possible. It may be optimal in some cases, but we can’t always guarantee that this is the best solution. The greedy search may be faster and simpler than the correct solution, that’s why it is used instead of a more complex one.

The examples are searching optimal paths on graph problems. In The Travelling Salesman Problem, the point is to find the shortest path to connect all the cities, and each city must be visited only once. This problem has no solution, and we can try to apply some greedy approach: for each new city, select the nearest unvisited city, for example. But we can’t prove or guarantee that a found solution will be optimal.

The Dijkstra algorithm from the last chapter reaches the optimal solution, but only for positive-weighted edges, and we can’t guarantee it for negative-weighted edges.

Anyway, the Greedy approach is common-used and applicable, and we’ll solve some problems with it.

Close-packing of equal spheres problem is one of the unsolved problems where the Greedy approach isn’t applicable. There are known solutions only for dimensions of size 1, 2, 3, 8, and 24.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 1
toggle bottom row

bookWhy Greedy?

Why Greedy?

The aim of the Greedy approach is to reach the optimal solution as fast as possible. It may be optimal in some cases, but we can’t always guarantee that this is the best solution. The greedy search may be faster and simpler than the correct solution, that’s why it is used instead of a more complex one.

The examples are searching optimal paths on graph problems. In The Travelling Salesman Problem, the point is to find the shortest path to connect all the cities, and each city must be visited only once. This problem has no solution, and we can try to apply some greedy approach: for each new city, select the nearest unvisited city, for example. But we can’t prove or guarantee that a found solution will be optimal.

The Dijkstra algorithm from the last chapter reaches the optimal solution, but only for positive-weighted edges, and we can’t guarantee it for negative-weighted edges.

Anyway, the Greedy approach is common-used and applicable, and we’ll solve some problems with it.

Close-packing of equal spheres problem is one of the unsolved problems where the Greedy approach isn’t applicable. There are known solutions only for dimensions of size 1, 2, 3, 8, and 24.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Why Greedy?

The aim of the Greedy approach is to reach the optimal solution as fast as possible. It may be optimal in some cases, but we can’t always guarantee that this is the best solution. The greedy search may be faster and simpler than the correct solution, that’s why it is used instead of a more complex one.

The examples are searching optimal paths on graph problems. In The Travelling Salesman Problem, the point is to find the shortest path to connect all the cities, and each city must be visited only once. This problem has no solution, and we can try to apply some greedy approach: for each new city, select the nearest unvisited city, for example. But we can’t prove or guarantee that a found solution will be optimal.

The Dijkstra algorithm from the last chapter reaches the optimal solution, but only for positive-weighted edges, and we can’t guarantee it for negative-weighted edges.

Anyway, the Greedy approach is common-used and applicable, and we’ll solve some problems with it.

Close-packing of equal spheres problem is one of the unsolved problems where the Greedy approach isn’t applicable. There are known solutions only for dimensions of size 1, 2, 3, 8, and 24.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 1
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt