Question: I'm doing a c++ program. I encountered a problem for defining the base case for recursion and how recursion works for this one. Basically, I
I'm doing a c++ program. I encountered a problem for defining the base case for recursion and how recursion works for this one. Basically, I have a string vector and I want to compare and match the user's input string with each element in that vector, then return an integer which represents the position of that matched element in the vector.
I finished the iterative way and the code is below:
for(int i = 0; i < data.size(); i++){
if(query == data.at(i)){
return i;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
