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
Step: 1
Get Instant Access with AI-Powered 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