0%
0 / 8 answered
Recursion Practice Test
•8 QuestionsQuestion
1 / 8
Q1
How many recursive calls are made by isPal("abba") before reaching the base case?
boolean isPal(String s) {
if (s.length() <= 1) return true;
if (s.charAt(0) != s.charAt(s.length()-1)) return false;
return isPal(s.substring(1, s.length()-1));
}
```
How many recursive calls are made by isPal("abba") before reaching the base case?
boolean isPal(String s) {
if (s.length() <= 1) return true;
if (s.charAt(0) != s.charAt(s.length()-1)) return false;
return isPal(s.substring(1, s.length()-1));
}
```