Computer Science EngineeringHardISRO SC (CS)

The number of distinct permutations of 1..6 that can be produced as output by pushing 1,2,...,6 in order onto a stack and popping at any time is:

  1. A. 138
  2. B. 132
  3. C. 66
  4. D. 429

Correct answer: B. 132

Stack-permutations are counted by the Catalan number C6 = 132 (same as the number of binary trees on 6 nodes).

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic