Let's look at an example first(which we learnt in class):
All recursion need a base case and a recursion step.
What I think difficult to do is to build the recursion step, it is really hard for me to find the relation ship between the base case and the current case. I was struggled for a long time on e2.
But fortunately, one of my friend taught me that I shouldn't think too much on the whole procedure, just figure out the relationship by simplify the current cases.
I did so, and was surprised to find I am done, I made it. It is no doubt that recursion is not that difficult, just analyse in a right way, every one can grasp it.
All recursion need a base case and a recursion step.
What I think difficult to do is to build the recursion step, it is really hard for me to find the relation ship between the base case and the current case. I was struggled for a long time on e2.
But fortunately, one of my friend taught me that I shouldn't think too much on the whole procedure, just figure out the relationship by simplify the current cases.
I did so, and was surprised to find I am done, I made it. It is no doubt that recursion is not that difficult, just analyse in a right way, every one can grasp it.

ya i guess you must be very good with recursion now!
ReplyDeletewell... always building from the bottem of recursion. I mean it. linkedlist for example, if you try to use recursion, begin from None, not the listnode which points to None and contains something. You will find some tiny change can simplify your code a lot.
ReplyDelete