educative.io

Is sorting needed in bottom-up approach for MCC

Just want to know if sorting the coins is needed for MCC (Min. coin change) in bottom-up approach.
In the Max. ribbon cut problem’s bottom-up approach, sorting was not done.
Could anyone please help clarify it.

Actually, it is not needed. Thanks for pointing this out, Vishnu! Since we are initializing the ‘dp’ array with “Integer.MAX_VALUE” and processing all ‘totals’ for every denomination, this should cover all combinations, irresptive of the order. We have corrected it.