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:
- A. 436
- B. 215
- C. 1430
- 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).
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- How many structurally distinct binary trees (left and right children distinguished) with exactly 6 nodes have height exactly 4 edges?
- Using the Master theorem (extended form), the solution of T(n) = 2T(n/4) + n is:
- The keys [10, 14, 40, 49, 41, 19, 38] are inserted in this order into an initially empty AVL tree. Its preorder traversal is:
- A connected simple undirected graph has 8 vertices and 12 edges. The minimum number of edges that must be removed to obtain a spanning…
- A connected simple undirected graph has 10 vertices and 17 edges. The minimum number of edges that must be removed to obtain a spanning…
- The worst-case number of key comparisons binary search makes on a sorted array of 7 elements (counting one three-way comparison per probe)…