I was hoping for a little help on this subject. I am trying to find all the permutations of a vector. Ive done a bit of research and could only find a recursive solution. Recursion still kind of confuses me, so I was wondering if anyone could help with a non recursive version? Heres what I have so far:

Code:void perm(vector<int>v, int num, int curNum, int posNum, int &output) { v.insert(v.begin()+posNum, curNum);//puts the current number into the desired position if(curNum == num)//stop case { print(v, num, output);//print function return; } for(int i=0; i <= curNum; i++) { perm(v, num, curNum+1, i, output);//recursive call } }