Computer Science EngineeringHardISRO SC (CS)

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

  1. A. 436
  2. B. 215
  3. C. 1430
  4. D. 429

Correct answer: D. 429

Stack-permutations are counted by the Catalan number C7 = 429 (same as the number of binary trees on 7 nodes).

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

Exams that ask this topic