International Journal of Computer Applications |
Foundation of Computer Science (FCS), NY, USA |
Volume 178 - Number 15 |
Year of Publication: 2019 |
Authors: Ashar Mehmood |
![]() |
Ashar Mehmood . ASH CC Algo.: Coin Change Algorithm Optimization. International Journal of Computer Applications. 178, 15 ( May 2019), 1-9. DOI=10.5120/ijca2019918787
The Coin Change problem is to represent a given amount V with fewest number of coins m. As a variation of knapsack problem, it is known to be NP-hard problem. Most of the time, Greedy alogrithm (time complexity O(m), space complexity O(1)), irrespective of real money system, doesn’t give optimal solution. Dynamic algorithm (time complexity O(mV), space complexity O(V)) gives optimal solution but is still expensive as amount V can be very large. In this paper, we have presented a suboptimal solution for the coin change problem which is much better than the greedy algorithm and has accuracy comparable to dynamic solution. Moreover, comparison of different algorithms has been stated in this paper. Proposed algorithm has a time complexity of O(m2f) and space complexity of O(1), where f is the maximum number of times a coin can be used to make amount V. It is, most of the time, more efficient as compared to dynamic algorithm and uses no memoization, this is a significant advantage over dynamic approach.