Quick Quiz on Recursion with Strings!
This quiz will test your understanding of recursion in strings
1
The task is to replace all occurrences of ‘e’ with ‘a’ using recursion.
void replace(string& text, int index, int lenString)
{
//base case
if(index == lenString-1)
return
else
//recursive case
}
What should be the recursive case of the following code?
A)
replace(text,index+1,lenString)
B)
replace(text.substr(1),index,lenString)
C)
replace(text, index+1, lenString-1)
D)
replace(text.substr(1),index,lenString-1)
Question 1 of 20 attempted
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.