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

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!