
The knapsack problem is an optimization problem in computer science which involves determining the most valuable combination of items that can be packed into a knapsack (a container) with a limited capacity (weight or volume); the goal is to maximize the total profit of the items included in the knapsack without exceeding its capacity. This study extensively analyzes the knapsack problem, exploring the application of three prevalent heuristics: greedy, dynamic programming, and FPTAS algorithms implemented in Python. The study aims to assess how these algorithms perform differently, focusing on program complexity and computational speed. Our main objective is to compare these algorithms and determine the most effective one for solving the knapsack problem as well as to be chosen by the researchers and developers when dealing similar problem in real-world applications. Our methodology involved solving the knapsack problem using the three algorithms within a unified programming environment. We conducted experiments using varying input datasets and recorded the time complexities of the algorithms in each trial. Additionally, we performed Halstead complexity measurements to derive the volume of each algorithm for this study. Subsequently, we compared program complexity in Halstead metrics and computational speed for the three approaches. The research findings reveal that the Greedy algorithm demonstrates superior computational efficiency compared to both Dynamic Programming (D.P) and FPTAS algorithms across various test cases. To advance understanding of the knapsack problem, future research should focus on investigating the performance of other programming languages in addressing combinatorial optimization problems, which would provide valuable insights into language choice impact. Additionally, integrating parallel computing techniques could accelerate solution processes for large-scale problem instances.
Halstead metrics, Python programming, Time complexity, NP-Hard, Heuristic, FPTAS
Halstead metrics, Python programming, Time complexity, NP-Hard, Heuristic, FPTAS
| citations This is an alternative to the "Influence" indicator, which also reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically). | 0 | |
| popularity This indicator reflects the "current" impact/attention (the "hype") of an article in the research community at large, based on the underlying citation network. | Average | |
| influence This indicator reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically). | Average | |
| impulse This indicator reflects the initial momentum of an article directly after its publication, based on the underlying citation network. | Average |
