Data Structures & AlgorithmsModerateProduct-company placement
What is the length of the shortest string that has BOTH COMPILER and SHORTEST as subsequences (shortest common supersequence)?
- A. 16
- B. 15
- C. 10
- D. 14
Correct answer: D. 14
SCS length = |a| + |b| − LCS = 8 + 8 − 2 = 14; the common subsequence is written once and the other letters of both words are woven around it.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Prim's algorithm starts at G on the weighted undirected graph A–B (19), A–F (12), A–G (21), B–C (13), B–D (23), B–E (6), B–G (29), D–E…
- The weighted undirected graph A–B (1), A–C (6), A–D (3), A–E (4), B–C (4), B–D (3), C–D (5) has repeated weights. How many different…
- A simple undirected graph has 9 vertices and exactly 4 connected components. What is the maximum possible number of edges?
- With 3 identical eggs and at most 6 drops, what is the largest number of floors for which you can always determine the critical floor (the…
- A 4 × 4 grid has rows 1 3 8 3 / 7 6 6 2 / 4 9 8 9 / 9 8 4 5. Moving only right or down from the top-left to the bottom-right cell, what is…
- Keys 85, 36, 65, 27, 34, 80, 17, 66, 97, 68 are inserted in order into an empty AVL tree. Counting a double rotation as two single…