Question: What does Recursion Require? 1 . Termination Condition 2 . Call the Clone ( same function ) 3 . Move towards Termination Condition boolean isPal

What does Recursion Require?
1. Termination Condition
2. Call the Clone (same function)
3. Move towards Termination Condition boolean isPal(String s) Show the Activation Stack for ZEROREZ
{
if(s.length()==0|| s.length()==1)
// if length =0 OR 1 then it is
return true;
if(s.charAt(0)== s.charAt(s.length()-1))
// check first and last char of String:
// if same then do same for substring
// for substring and carry on this
// remove first and last char.
return isPal(s.substring(1, s.length()-1));
// if its not the case than string is not.
return false;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!