Subcaterpillar Isomorphism: Subtree Isomorphism for Rooted Labeled Caterpillars
摘要
A subtree isomorphism, which is one of the pattern matching for rooted labeled trees (trees, for short), is the problem of determining whether or not, for a pattern tree P, there exists a subtree in a text tree T which is isomorphic to P. In this paper, we investigate the subtree isomorphism when P is a rooted labeled caterpillar (caterpillar, for short), which we call a subcaterpillar isomorphism of P in T. First, we investigate the subcaterpillar isomorphism when T is a tree. Then, we design two algorithms CatTreeIso and CatTreeIso2 to solve the subcaterpillar isomorphism of P in T and show that the algorithm CatTreeIso runs in \(O(tDh\sigma )\) time and O(Dh) space and the algorithm CatTreeIso2 runs in \(O(tD\sigma )\) time and \(O(D(h+H))\) space, respectively. Here, t is the number of vertices in T, h is the height of P, H is the height of T, \(\sigma \) is the number of alphabets for labels and D is the degree of T. Next, we investigate the subcaterpillar isomorphism when T is a caterpillar, which we call a subcaterpillar isomorphism between caterpillars. Then, by simplifying the algorithms CatTreeIso and CatTreeIso2, we design two algorithms CatCatIso and CatCatIso2 to solve the subcaterpillar isomorphism between caterpillars of P in T. Then, we show that both algorithms run \(O(hH\sigma )\) time and O(h) space. Finally, by implementing the algorithms CatTreeIso, CatTreeIso2, CatCatIso and CatCatIso2, we give experimental results of the subcaterpillar isomorphism and the subcaterpillar isomorphism between caterpillars for both artificial and real data.