Two standard textbook problems illustrating dynamic programming are to find the longest common subsequence (LCS) between two strings and to find the longest palindromic subsequence (LPS) of a single string. A popular claim is that the longest palindromic subsequence in a string can be computed as the longest common subsequence between the string and the reversed string. We prove that the correctness of this claim depends on how the longest common subsequence is computed. In particular, we prove that the classical dynamic programming solution by Wagner and Fischer [JACM 1974] for finding an LCS in fact does find an LPS, while a slightly different LCS backtracking strategy makes the algorithm fail to always report a palindrome.
@InProceedings{brodal_et_al:LIPIcs.ESA.2024.35, author = {Brodal, Gerth St{\o}lting and Fagerberg, Rolf and Rysgaard, Casper Moldrup}, title = {{On Finding Longest Palindromic Subsequences Using Longest Common Subsequences}}, booktitle = {32nd Annual European Symposium on Algorithms (ESA 2024)}, pages = {35:1--35:16}, series = {Leibniz International Proceedings in Informatics (LIPIcs)}, ISBN = {978-3-95977-338-6}, ISSN = {1868-8969}, year = {2024}, volume = {308}, editor = {Chan, Timothy and Fischer, Johannes and Iacono, John and Herman, Grzegorz}, publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik}, address = {Dagstuhl, Germany}, URL = {https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ESA.2024.35}, URN = {urn:nbn:de:0030-drops-211068}, doi = {10.4230/LIPIcs.ESA.2024.35}, annote = {Keywords: Palindromic subsequence, longest common subsequence, dynamic programming} }
Feedback for Dagstuhl Publishing