GATE Computer ScienceHardGATE CS (PYQ pattern)
Among all full parenthesisations of the product A₁A₂A₃A₄A₅A₆A₇, how many contain the product (A₃A₄) as one of their sub-products?
- A. 132
- B. 42
- C. 70
- D. 14
Correct answer: B. 42
If A₃A₄ is computed as a unit, it behaves like a single matrix, so the chain has 6 factors and there are C₅ = 42 parenthesisations. All 7-factor parenthesisations number C₆ = 132; 70 counts those containing (A₃A₄) or (A₅A₆); 14 those containing both.
More Algorithms questions
- X = ABCBDAB and Y = BDCABA have longest common subsequences of length 4. How many DIFFERENT strings are shortest common supersequences of…
- The fractional knapsack greedy algorithm (taking items by value/weight ratio, the last one fractionally) is run on capacity 26 and items…
- Dijkstra's algorithm (never re-inserting or re-opening a vertex once it has been extracted) is run from S on a directed graph with edges…
- Dijkstra's algorithm with a binary min-heap (lazy insertion is not used: a decrease-key is performed whenever an edge improves the label…
- In the undirected weighted graph with edges SA 1, SB 1, SC 2, AD 2, BD 2, CD 1, AE 3, BE 3, CE 2, DT 2, ET 1 and AB 1, how many distinct…
- Bellman–Ford is run from A on a 6-vertex graph with directed edges relaxed in this fixed order in every pass: E→F 2, D→E 3, C→D 2, B→C 4…