Question: It has segmentation fault. How to fix it? #include #include using namespace std; vector insert(const vector & prev, int pos, int elem){ vector v; for

It has segmentation fault. How to fix it?

#include #include

using namespace std;

vector insert(const vector & prev, int pos, int elem){ vector v; for (int i=0; i

return v; }

vector > getPermutationssOfOneToN(int n){ vector > v; vector s; if (n<=0){ v.push_back(s); return v; } else{ vector > v2 = getPermutationssOfOneToN(n-1); // all permutations of {1 .. n-1} for (int i=0; i new_perm = insert(s,j,n); v.push_back(new_perm); } } return v; } }

void print_vector(const vector& v){ for (int i=0; i

int main(){ for (int i= 1; i<5; i++){ cout << "permutationss of {1.." << i << "}:" << endl; vector > perms = getPermutationssOfOneToN(i); for (vector >::iterator itr=perms.begin(); itr

}

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!