recursion and call stack problem
i have this code,
static String reverse(String s) {
if (s.length() <= 1) {
return s;
}
return reverse(s.substring(1)) + s.charAt(0);
}
and these two questions,
1.Explain the algorithm.
2.Rewrite the recursion and implement it iteratively. Use the same method signature, but call the method reverseIterative. Use a while-loop in your implementation, and implement the same approach you answered in the previous question.
im new to recursions,
can anyone help and explain?
thanks.
OP