Data Structures & AlgorithmsHardProduct-company MCQ pattern
What is the length of the longest palindromic SUBSEQUENCE of CHARACTER?
- A. 4
- B. 7
- C. 5
- D. 3
Correct answer: C. 5
C A R A C (positions 1, 3, 4, 5, 6 of CHARACTER) is a palindrome of length 5, and the DP gives no longer one. 3 is the longest palindromic SUBSTRING (ARA); a subsequence need not be contiguous.
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
- Coins of 1, 5, 6 and 8 are available in unlimited supply. For amount 11, how many coins does the 'largest coin first' greedy method use…
- Each job takes 1 unit of time; only one job runs at a time. Jobs (deadline, profit): J1 (2, 100), J2 (1, 19), J3 (2, 27), J4 (1, 25), J5…
- Characters a, b, c, d, e occur 4, 7, 9, 12 and 20 times. With an optimal Huffman code, how many bits are needed to encode the whole text?
- Bellman–Ford from A relaxes the directed edges in the fixed order C→D (2), B→C (3), A→B (4), A→C (9), B→D (7). After the FIRST full pass…
- A directed graph has edges 1→2, 2→3, 3→1, 3→4, 4→5, 5→6, 6→4, 6→7, 7→8. How many strongly connected components does it have?
- An undirected graph has edges 1–2, 2–3, 3–1, 3–4, 4–5, 5–6, 6–4, 6–7. How many articulation points (vertices whose removal disconnects the…