1,504 views

1 Answer

3 votes
3 votes

Case 1:
Push 1, pop 1
push 2, pop 2
push 3, pop 3

Case 2:
push 1
Push 2, Pop 2
Pop 1
push 3, pop 3


As we can see there 2 possibilities before 3(1, 2 and 2, 1), and there will be 4 possibilities after 3  (456, 546, and 564, 654,465).
so far we got 10 sequences.
Remaining 16 will be as follows:

4 5 3 2 1 6
4 5 3 2 6 1
4 5 3 6 2 1
5 4 3 2 6 1
5 4 3 6 2 1
5 4 3 2 1 6

143256

143265

143526

143562

143652

243156

243165

243516

243561

243651

Hence, there total 26 sequences possible.

edited

Related questions

2 votes
2 votes
2 answers
1
1 votes
1 votes
2 answers
2
Shamim Ahmed asked Dec 11, 2018
689 views
Every recursive program uses strictly more stack space compared to its iterative equivalent.This statement is false. Please explain with examples
2 votes
2 votes
0 answers
3
1 votes
1 votes
1 answer
4
radha gogia asked Jul 24, 2018
1,309 views
Suppose one character at a time comes as an input from a string of letters . There is an option either to 1) print the incoming letter or to 2) put the incoming letter on...