Monday, June 27, 2011

reversing a String

Native recursion:
-remove first character
-reverse the res of the string
-add (former) first character to the end of the string


Steps to develope a recursive algorithm:

1) Can I divide the problem at hand into smaller problems of the same type?
2) given a sufficiently small instance of the problem, is it simple (or trivial) to find the answer?

--> BASE CASES <--

3) given answers to the smaller problems,
can I reassemble the answers to get an answer for the whole problem?

No comments:

Post a Comment