GATE Computer ScienceVery hardGATE CSE · ISRO
Strings X = ABCBDABA and Y = BDCABAB are given. How many distinct longest common subsequences (distinct as strings) do they have?
- A. 4
- B. 6
- C. 3
- D. 2
Correct answer: C. 3
The LCS length is 5 and the DP back-trace (taking both branches on ties and de-duplicating) yields 3 different strings: BCABA, BCBAB, BDABA.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- Words car, card, care, cart, cat, dog, door, dot, dove, do, cargo, carbon, catalog, cat are inserted into an initially empty trie (a…
- A B-tree of order 5 (each node holds at most 4 keys) is built by inserting 1, 2, 3, …, 60 in increasing order. When a node overflows to 5…
- How many different arrays A[1..9] that are permutations of {1,…,9} satisfy the min-heap property (A[i] ≥ A[⌊i/2⌋] for every i ≥ 2)?
- What is the minimum number of comparisons needed in the worst case to find both the maximum and the minimum of 101 distinct numbers using…
- The KMP failure (prefix) function π[i] of pattern P = "abaabaabaabab" gives, for each prefix P[0..i], the length of its longest proper…
- A hash table with 7 buckets uses separate chaining, h(k) = k mod 7, and every new key is inserted at the head of its chain. The keys 50…