The answer of data structures and program design in C++,Exercses2.1;E4
(a)For n = 3,all possible permutations is 123,132,213,231,321;
(b)For n = 4,all possible permutations is 1234,1243,1324,1342,1432,2134,2143,2341,2314,2431,3214,3241,3421,4321;
(c)For general n,by use this stack have a(n) = a(0)*a(n - 1)+a(1)*a(n - 2) + ... + a(n - 1)*a(0) permutations. (Consult some material becouse of difficult.)
a(0) = 1;
a(1) = 1;
a(2) = 2;a(2) = a(0)*a(1) + a(1)*a(0) = 1*1 + 1*1 =2;12,21,
a(3) = 5;a(3) = a(0)*a(2) + a(1)*a(1) + a(2)*a(0) = 1*2 + 1*1 + 2*1 = 5;
a(4) = 13;a(4) = a(0)*a(3) + a(1)*a(2) + a(2)*a(1) + (3)*a(0) = 1*5 + 1*2 + 2*1 + 5*1 = 14;