Show the call stack for isPalindrome("abcba") using the method defined in Listing 1.
LISTING 1 RecursivePalindromeUsingSubstring.java
1 public class RecursivePalindromeUsingSubstring {
2 public static boolean isPalindrome(String s) {
3 if (s.length() <= 1) // Base case
4 return true;
5 else if (s.charAt(0) != s.charAt(s.length() - 1)) // Base case
6 return false;
7 else
8 return isPalindrome(s.substring(1, s.length() - 1));
9 }
10
11 public static void main(String[] args) {
12 System.out.println("Is moon a palindrome? "
13 + isPalindrome("moon"));
14 System.out.println("Is noon a palindrome? "
15 + isPalindrome("noon"));
16 System.out.println("Is a a palindrome? " + isPalindrome("a"));
17 System.out.println("Is aba a palindrome? " +
18 isPalindrome("aba"));
19 System.out.println("Is ab a palindrome? " + isPalindrome("ab"));
20 }
21 }

We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.