Hi there
Can anyone supply me with a source for exercises in Recursion?
I need to practice and do not have but a few exercises
Cheers
Gozlan
Hi there
Can anyone supply me with a source for exercises in Recursion?
I need to practice and do not have but a few exercises
Cheers
Gozlan
A simple exercise is to write a function that calls itself until it returns an a predetermined value of some sort.
I learned by using an integer and having the function call itself until it returned 3, or 5 or whatever.
Once you learn how to do this type of recursion, I think it becomes much easier.
> I need to practice and do not have but a few exercises
That's the perfect amount of times for recursion to be used too, just a few.
The world is waiting. I must leave you now.
I'll beat Salem to the punch. Here is an example of recursion.
If you want something to use recursion for, how about a maze generator?
Naturally you'd want this to update 'here' on the additional calls, but I'll leave that as an exercise to you.Code:void move( here, direction ) { if( unusedNeighboringCell( here ) ) move( here, randomUnusedNeighboringCellDirection( ) ) ) else return }
Quzah.
Hope is the first step on the road to disappointment.