Research Article

Comparison of dynamic programming and greedy algorithms and the way to solve 0-1 knapsack problem

Yitian Wu*
School of Computer Science, Central South University for Nationalities, Wuhan, Hubei Province, China, 430000

* Corresponding author: [email protected]

Abstract

The 0-1 knapsack problem is widely used in reality and it belongs to NP-hard problems. Starting from the basic ideas and time complexity of the algorithm, this paper analyzes how to choose a strategy to solve the problem. This paper aims to solve practical problems and analyzes the 0-1 knapsack problem in combination with the real-life cargo delivery problem. Dynamic programming and greedy algorithms are used to tackle the problem respectively, and the advantages and disadvantages of two strategies are discussed, so as to analyze how to decide which strategy to adopt to solve the problem when encountering the 0-1 knapsack problem in an actual situation. In the face of large-scale problems, this paper suggests choosing greedy algorithm because it will save a lot of time. In the face of small-scale problems that require absolute solutions, this paper suggests choosing dynamic programming to solve the problem.

Keywords: 0-1 Knapsack Problem; Dynamic Programming; Greedy Algorithm; Maximal Knapsack Packing; Optimal Solution.
Published: May 31, 2023
DOI: 10.54254/2755-2721/5/20230666
Volume: ACE Vol.5
pp. 631-636
Download PDF

References

  1. Martello, S., & Toth, P. (1990). Knapsack problems: Algorithms and computer implementations. Chichester: John Wiley & Sons.
  2. Bellman, R. (1957). Dynamic programming. Princeton University Press.
  3. Boyar, J., Epstein, L., Favrholdt, L. M., Kohrt, J. S., Larsen, K. S., Pedersen, M. M., et al. (2006). The maximum resource bin packing problem.Theoretical Computer Science, 362(1–3), 127–139.
  4. Martello, S., & Toth, P. (1990). Knapsack problems: Algorithms and computer implementations. Chichester: John Wiley & Sons.
  5. Glover, F. (2013). Advanced greedy algorithms and surrogate constraint methods for linear and quadratic knapsack and covering problems. European Journal of Operational Research, 230(2), 212–225.
  6. Kellerer, H., Pferschy, U., & Pisinger, D. (2004). Knapsack problems. Berlin: Springer.
  7. Martello, S., Pisinger, D., & Toth, P. (1999). Dynamic programming and strong bounds for the 0-1 knapsack problem. Management Science, 45, 414–424.
  8. Pisinger, D. (1995). A minimal algorithm for the multiple-choice knapsack problem. European Journal of Operational Research, 83(2), 394–410.
  9. Pisinger, D. (2007). The quadratic knapsack problem – a survey. Discrete Applied Mathematics, 155(5), 623–648.
  10. Gai, L., & Zhang, G. (2009). Hardness of lazy packing and covering. Operations Research Letters, 37(2), 89–92.