Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Which of the following statements are true about the two functions defined here? string reverse _ str ( string str ) { string val =
Which of the following statements are true about the two functions defined here?
string reversestrstring str
string val ;
if str strlength
return str;
string first strsubstr;
string rest strsubstr strlength;
val reversestrrestappendfirst;
return val;
string iterreversestring str
int len strlength;
int mid len ;
for int i ; i mid; i
char ch stri;
int pos len i ;
stri strpos;
strpos ch;
return str;
Question options:
The reverse function is a recursive solution, and the iterreverse function is an iterative solution.
The two functions execute at about the same speed.
For a string of length n the reverse function makes about n recursive calls but the iterreverse function performs about n iterations.
All of the above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started