Question: Integer vectSize is read from input, then vectSize ints are read and stored in vector tokensToPick. Complete the CreateSequence() recursive case to perform the following
Integer vectSize is read from input, then vectSize ints are read and stored in vector tokensToPick. Complete the CreateSequence() recursive case to perform the following tasks:
Move the element at index i of remainTokens to the end of pickedTokens.
Recursively call CreateSequence().
Move the element from the end of pickedTokens back to index i of remainTokens.
Ex: If the input is 3 7 8 11, then the output is:
All possible sequences: 7:8:11: 7:11:8: 8:7:11: 8:11:7: 11:7:8: 11:8:7:
Note:
vector.erase(vector.begin() + i) removes the element at index i of vector.
vector.insert(vector.begin() + i, x) insert x into vector at index i.
#include
void CreateSequence(vector
} } }
int main() { vector
cout << "All possible sequences:" << endl; CreateSequence(tokensToPick, picks); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
