Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in C++ Given the following recursive function: string mystery(string s) return i

ID: 3904337 • Letter: I

Question

in C++

Given the following recursive function: string mystery(string s) return i ()r if (toupper s]) 'A' 11 toupper (s 'E Il toupper(s[ 0 ])--T Il toupper(s[ 0 ])-= .0' II toupper(sI ) U') return s.substr(0, 1) mystery(s.substr(1, s.size() 1)) return ""+mystery(s.substr(1, s.size() -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 2. mystery" 3. mystery 4. mystery 5. mystery("") returns "" to Call #4. Describe what the mystery method accomplishes. to result ") returns ) returns ) returns to Call to Call #2 to Call

Explanation / Answer

1. mystery("Omar") returns "Oa" to result

2. mystery("mar") returns "a" to Call #3

3. mystery("ar") returns "a" to Call #3

4. mystery("r") returns "" to Call #3

5. mystery("") returns "" to Call #4

Describe what mystery method accomplishes:

mystery() method takes a string as input and retains only the vowels. Considers both lowercase and uppercase vowels and retains them in the case they appear. Rest of the letters are replaced by empty string.