reset password
Author Message
jgarc659
Posts: 27
Posted 20:49 Nov 20, 2017 |

So, to my understanding, the instructions for method 2 explain that we run through the input string from left to right, and while doing so, store the first character in the string, remove it from the string, and then place it at the end of the string - finishing when we've done this for every character. However, this process just ends up returning the same string we started with. Am I misunderstanding the instructions? Or do we conduct similar operations (removing and replacing characters in a string) in a way that would actually return a reversed string?

Also, would it be acceptable to use non-recursive methods that call a recursive method with an additional parameter, similar to part 2 of today's programming exercise?

Thanks.

jhurley
Posts: 207
Posted 08:16 Nov 21, 2017 |

The new string gets reconstructed as the call string unwinds, so the rebuilding of the string happens in the opposite order from the deconstruction.  Think about what happens on the call stack.

jgarc659
Posts: 27
Posted 10:44 Nov 21, 2017 |
jhurley wrote:

The new string gets reconstructed as the call string unwinds, so the rebuilding of the string happens in the opposite order from the deconstruction.  Think about what happens on the call stack.

Thank you, I'll approach it with that in mind.
Also, are we allowed to use the method I described, in which an initial non-recursive method calls an overloaded recursive method with additional parameter(s), like in yesterday's exercise?

jhurley
Posts: 207
Posted 11:26 Nov 21, 2017 |

yes