Question: Which of following is true about the reverse _ string function used in solving the problem of reversing a string? string reverse _ substring (

Which of following is true about the reverse_string function used in solving the problem of reversing a string?
string reverse_substring(string str, int start, int end)
{
if (start >= end)
{
return str;
}
char ch = str[start];
str[start]= str[end];
str[end]= ch;
return reverse_substring(str, start +1, end -1);
}
string reverse_string(string str)
{
return reverse_substring(str,0, str.length()-1);
}
Question 5 options:
The reverse_string function is a recursive function.
The reverse_string function is an iterative function.
The reverse_string function uses reverse_substring as a helper function.
The reverse_substring function uses reverse_string as a helper function.

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 Databases Questions!