Which of the following is not a palindromic subsequence of the string…

2023

Which of the following is not a palindromic subsequence of the string "ababcdabba" ?

  1. A.

    abcba

  2. B.

    abba

  3. C.

    abbbba

  4. D.

    adba

Attempted by 295 students.

Show answer & explanation

Correct answer: D

Answer: adba is not a palindromic subsequence.

Reasoning and examples of subsequence indices:

  • abcba — indices 1, 2, 5, 8, 10 give a b c b a, which reads the same forwards and backwards, so it is a palindromic subsequence.

  • abba — indices 1, 2, 9, 10 give a b b a, a palindrome, so this is a palindromic subsequence.

  • abbbba — indices 1, 2, 4, 8, 9, 10 give a b b b b a, which is symmetric and therefore a palindromic subsequence.

  • adba — indices 1, 6, 8, 10 give a d b a, so it is a subsequence, but it is not a palindrome because reversing it gives a b d a (the middle letters differ), therefore it is not a palindromic subsequence.

Conclusion: Among the given strings, adba is the only one that is not a palindromic subsequence.

Explore the full course: Coding For Placement