arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2210.07979cs.DS
收藏

更快且空间高效的 STR-IC-LCS 计算

Faster Space-Efficient STR-IC-LCS Computation

Yuki Yonemoto, Yuto Nakashima, Shunsuke Inenaga, Hideo Bannai

AI总结:

本文研究字符串必须包含 P 为子串的 STR-IC-LCS 问题,提出三种兼顾时间与空间效率的动态规划算法,并给出多种复杂度界。

摘要:

比较两个给定字符串 A 和 B 的最基本方法之一是最长公共子序列(LCS),其任务是找到 A 与 B 的一个 LCS(及其长度)。本文研究 STR-IC-LCS 问题,它是 Chen 和 Chao [J. Comb. Optim, 2011] 提出的约束 LCS 问题之一。对于三个给定字符串 A、B 和 P,若字符串 Z 是满足以下条件的最长字符串,则称 Z 为它们的 STR-IC-LCS:(1)Z 将 P 作为子串包含;(2)Z 是 A 和 B 的公共子序列。我们针对该问题提出三种高效算法:首先,我们从一种空间高效的解决方案开始,它在 O(n^2) 时间和 O((ℓ+1)(n−ℓ+1)) 空间内计算 STR-IC-LCS 的长度,其中 ℓ 是长度为 n 的 A 与 B 的 LCS 长度。当 ℓ=O(1) 或 n−ℓ=O(1) 时,该算法仅使用线性 O(n) 空间。其次,我们提出一种更快的算法,其运行时间为 O(nr/log r+n(n−ℓ+1)),其中 r 是 P 的长度,同时保持 O((ℓ+1)(n−ℓ+1)) 的空间效率。第三,我们给出另一种可选算法,运行时间为 O(nr/log r+n(n−ℓ′+1)),空间复杂度为 O((ℓ′+1)(n−ℓ′+1)),其中 ℓ′ 表示输入字符串 A、B 和 P 的 STR-IC-LCS 长度。

英文摘要:

One of the most fundamental method for comparing two given strings $A$ and $B$ is the longest common subsequence (LCS), where the task is to find (the length) of an LCS of $A$ and $B$. In this paper, we deal with the STR-IC-LCS problem which is one of the constrained LCS problems proposed by Chen and Chao [J. Comb. Optim, 2011]. A string $Z$ is said to be an STR-IC-LCS of three given strings $A$, $B$, and $P$, if $Z$ is a longest string satisfying that (1) $Z$ includes $P$ as a substring and (2) $Z$ is a common subsequence of $A$ and $B$. We present three efficient algorithms for this problem: First, we begin with a space-efficient solution which computes the length of an STR-IC-LCS in $O(n^2)$ time and $O((\ell+1)(n-\ell+1))$ space, where $\ell$ is the length of an LCS of $A$ and $B$ of length $n$. When $\ell = O(1)$ or $n-\ell = O(1)$, then this algorithm uses only linear $O(n)$ space. Second, we present a faster algorithm that works in $O(nr/\log{r}+n(n-\ell+1))$ time, where $r$ is the length of $P$, while retaining the $O((\ell+1)(n-\ell+1))$ space efficiency. Third, we give an alternative algorithm that runs in $O(nr/\log{r}+n(n-\ell'+1))$ time with $O((\ell'+1)(n-\ell'+1))$ space, where $\ell'$ denotes the STR-IC-LCS length for input strings $A$, $B$, and $P$.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑