As it is you are leaving it to the reader to work out what algorithm is
supposed to be implemented by this pseudo-code, as well as what the
To me it looks like this is an attempt at a recursive function to find
the minimum number of coins to make change M from a coin set c[1..d],
but I am guessing. If I am right this is very far from being correct, and so
modification to return the optimal change set as well as the size of that
set is premature.
As a first step you should include comments on what all the parameters
are, what sort of thing bestNumCoins is (array, function ..?) and an
algorithm description in plain language.
Also is this the form of pseudo-code that you have been taught?