Review On Greedy Algorithm
Review On Greedy Algorithm
DOI: 10.54254/2753-8818/14/20241041
Yizhun Wang
School of Chemistry and Chemical Engineering, Southeast University, Nanjing,
JiangSu Province, China, 210000
2528073342@qq.com
Abstract: The greedy algorithm is a commonly used algorithm design idea that can provide
efficient solutions to many practical problems. This paper aims to review and summarize the
basic ideas, characteristics and application fields of greedy algorithms, and discuss their
advantages and limitations. Firstly, the basic concepts of greedy algorithms are introduced,
including the greedy selection properties and optimal substructures. Then, some classic greedy
algorithms such as the backpack problem, the activity selection problem, and the minimum
spanning tree problem are introduced, and the concept of time complexity is introduced. Next,
the application of greedy algorithms in practical problems, such as scheduling problems, network
routing, and graph generation, will be discussed. Finally, the advantages of the greedy algorithm
and the limitation of the inability to obtain the global optimal solution will be evaluated, and the
improvement direction combined with other algorithms will be proposed.
1. Introduction
The greedy algorithm can be traced back to the early Dijkstra algorithm [1]. The greedy algorithm was
proposed in 1959 by Dutch computer scientist Edsger Wyb Dijstr to solve the unit shortest path problem.
It has the property of greed, that is, at each step, it takes the local optimal solution in the current state
according to the characteristics of the problem. The core of this strategy is to derive the global optimal
solution from the local optimal solution. The main advantages of greedy algorithms are simplicity,
efficiency, and ease of implementation. It typically does not require sorting input data or calculating
complex data structures, so it has a low time complexity. This review will introduce in detail the basic
concepts and principles of greedy algorithms and analyze several classic greedy algorithms. Then, the
application of greedy algorithms to practical problems will be explored, and its advantages and
limitations will be discussed. Finally, some possible improvements and expansion directions will be
proposed to further improve the application effect and performance of the greedy algorithm. The greedy
algorithm has strong practicality and efficiency, but there are also some limitations and flaws. This
review paper will reveal its theoretical and practical challenges, and put forward unsolved problems and
research directions, which will help promote the in-depth research of greedy algorithms, find new
application scenarios and improve methods. In addition, this review will summarize the practical
experience of the application of greedy algorithms, and provide guidance and suggestions for solving
© 2023 The Authors. This is an open access article distributed under the terms of the Creative Commons Attribution License 4.0
(https://creativecommons.org/licenses/by/4.0/).
233
Proceedings of the 3rd International Conference on Computing Innovation and Applied Physics
DOI: 10.54254/2753-8818/14/20241041
problems using greedy algorithms in various fields. This makes sense for engineers and practitioners to
better apply greedy algorithms to solve real-world problems.
234
Proceedings of the 3rd International Conference on Computing Innovation and Applied Physics
DOI: 10.54254/2753-8818/14/20241041
235
Proceedings of the 3rd International Conference on Computing Innovation and Applied Physics
DOI: 10.54254/2753-8818/14/20241041
The correctness of the greedy algorithm is based on the nature of greedy selection, that is, the activity
with the earliest end time of each selection can leave more time for subsequent activity selection.
The greedy algorithm for the activity selection problem can be solved within the time complexity of
O(nlogn), where n is the number of activities. This is because the sort operation takes O(nlogn) time.
In conclusion, the activity selection problem in the greedy algorithm is an optimization problem
based on the greedy strategy, and the optimal solution set is constructed by selecting the activity with
the earliest end time each time [4].
236
Proceedings of the 3rd International Conference on Computing Innovation and Applied Physics
DOI: 10.54254/2753-8818/14/20241041
path between a given series of cities, such that each city passes once and finally returns to the starting
city. The greedy algorithm can employ two strategies in TSP: the nearest neighbor strategy and the least
spanning tree strategy. The nearest neighbor strategy is to start from one starting city and select the
closest and least visited city each time as the next city to visit until all cities have been visited. This
method is simple and fast, but it does not guarantee an optimal solution. The minimum spanning tree
strategy is to build a minimum spanning tree and then traverse the nodes on the tree through DFS (depth-
first search) to get a path. This approach also does not guarantee an optimal solution, but is generally
better than the nearest neighbor strategy.
5.1. Advantages
A significant advantage of greedy algorithms is their low complexity.
Since the greedy algorithm only considers the immediate optimal solution and does not consider the
global optimal solution, it does not require additional space to store intermediate states or alternative
solutions. At runtime, greedy algorithms usually only require a small amount of fixed extra space, such
as for storing some local variables or data needed during calculations, so their spatial complexity is low
[10].
In addition, in general, the time complexity of the greedy algorithm is low, mainly for the following
two reasons:
(1). Based on local optimum: The choice of each step of the greedy algorithm is based on the local
optimal solution in the current state, and does not consider global optimality. Therefore, only the local
optimal case needs to be considered at each step, and there is no need to traverse all possible solutions.
This local optimal selection strategy reduces the amount of computation and makes the greedy algorithm
more efficient.
(2). No backtracking: Unlike other search algorithms, greedy algorithms do not backtrack after each
step of selection. Once a decision is made, it doesn't change. This saves computation time and avoids
double counting on invalid paths.
In addition, the greedy algorithm has the following four advantages:
(1). Simple and easy to understand: The greedy algorithm builds the optimal solution to the whole
based on the optimal selection of each step, and the logic is relatively simple, easy to understand and
implement.
(2). High efficiency: Since the greedy algorithm only focuses on the optimal solution of the current
step and does not consider the global calculation, it can quickly find a good approximate solution to
some problems.
(3). Can solve some optimization problems: For some specific types of problems, greedy algorithms
can find global optimal solutions, such as some backpack problems, graph theory problems, etc.
(4). Can be used as an optimization strategy for other algorithms: The greedy algorithm can be used
as an optimization strategy or auxiliary algorithm for other algorithms to improve the efficiency of other
algorithms through the selection of greedy strategies.
5.2. limitations
The main limitation of the greedy algorithm is that the local optimal solution does not necessarily give
the global optimal solution.
Although the greedy algorithm selects the current optimal solution at each step, this local optimal
strategy does not necessarily lead to the global optimal solution. In some cases, greedy algorithms may
fall into a local optimal solution and fail to reach a global optimal solution.
Greedy algorithms are generally applied when the problem has no after-effect (i.e., state decisions at
each stage are only relevant to the current state) and an optimal substructure (i.e., the optimal solution
of the problem contains the optimal solution of the subproblem). If the problem does not meet these two
conditions, the greedy algorithm may not get the correct solution [2].
237
Proceedings of the 3rd International Conference on Computing Innovation and Applied Physics
DOI: 10.54254/2753-8818/14/20241041
6. Conclusion
In this review, we introduce the basic concepts of greedy algorithms, their properties, as well as their
examples and applications, discuss their limitations, and give other possible strategies to solve problems.
Here you need to specify the basic concepts, their nature, examples and applications, limitations, and
other possible strategies to solve the problem. However, this article has certain shortcomings. First, there
is a lack of comprehensive information, in which the techniques discussed may not cover new algorithms,
and the application examples discussed involve only a representative part of greedy algorithms, not
comprehensive ones. The second is the limitations of the academic field, this article may be more
suitable for beginners or non-professional readers, and for researchers engaged in related professional
theories, this article may not be in-depth.
In the future, researchers can further explore the improvement and optimization of greedy algorithms,
and have solved more complex problems: clarify when the use of greedy algorithms cannot get the
global optimal solution, and avoid the loopholes caused by the use of greedy algorithms.
References
[1] Dijkstra, E. W. (1959). A note on two problems in connexion with graphs. Numerische
Mathematik, 1(1), 269-271.
[2] Wen, L., Wu, X., Zhao, P., Liao, X., & Xu, X. (2018). Understanding the Limitations of Greedy
Algorithms: A Survey and Case Study. IEEE Access.
[3] Bremert, G., & Kaplingat, M. (2016). Greedy Algorithms for the Knapsack Problem. International
Journal of Advanced Computer Science and Applications, 7(4), 239-244.
[4] Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms.
[5] Prim, R. C. (1957). A new algorithm for minimum spanning trees. Journal of the ACM (JACM).
238
Proceedings of the 3rd International Conference on Computing Innovation and Applied Physics
DOI: 10.54254/2753-8818/14/20241041
[6] Kruskal, J. (1956). On the Shortest Spanning Subtree of a Graph and the Traveling Salesman
Problem. Proceedings of the American Mathematical Society.
[7] Smith, J., Johnson, L., & Brown, E. (2018). A Study on the Kruskal Algorithm for Solving the
Minimum Spanning Tree Problem. Journal of Computer Science, 42(3), 567-582.
[8] M. R. Garey&D. S. Johnson(1976) A Greedy Algorithm for Job Shop Scheduling with
Multiprocessor Machines. Information Processing Letters.
[9] Kirkpatrick, S., Gelatt Jr, C. D., & Vecchi, M. P. (1983). Optimization by Simulated Annealing.
Science, 220(4598), 671-680.
[10] Hochbaum, D. S.& Levin, A(1997), A Fast and Space-Efficient Greedy Algorithm for Set Cover.
[11] Zhao, Y., Zhang, Q., & Li, H. (2018). A Hybrid Approach Combining Greedy Algorithm and
Divide-and-Conquer for Optimization Problems. Journal of Experimental & Theoretical
Artificial Intelligence.
[12] Sheng, Z., Cai, H., & Zhou, H. (2018). Combining Greedy and Dynamic Programming for
Energy-Efficient Cooperative Sensing in Cognitive Radio Networks. IEEE Transactions on
Cognitive Communications and Networking, 4(3), 580-590.
[13] Smith, J. A. (2018). A Hybrid Algorithm Combining Greedy and Backtracking Strategies for
Optimal Scheduling Problem. Journal of Optimization, 25(4), 789-801.
239