Question: Given the following recursive function: public static String mystery ( String s ) { char [ ] temp = new char [ 1

Given the following recursive function:
public static String mystery(String s)
{
char [] temp = new char\[1\];
if (s.equals("")) return "";
if ("aeiouAEIOU".indexOf(s.charAt(0))!=-1)
{
temp\[0\]= s.charAt(0);
return new String(temp)+ mystery(s.substring(1));
}
else return ""+ mystery(s.substring(1));
}
Show all the calls to the function and what each one returns to its predecessor.
String result = mystery(Omar);
Call #
1. mystery(Omar) returns
to result
2. mystery(
) returns
to Call
3. mystery(
) returns
to Call #2
4. mystery(
) returns
to Call
5. mystery() returns to Call #4.

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!