/
PSC2019  Mitsuru Funakoshi PSC2019  Mitsuru Funakoshi

PSC2019 Mitsuru Funakoshi - PowerPoint Presentation

startlecisco
startlecisco . @startlecisco
Follow
343 views
Uploaded On 2020-10-22

PSC2019 Mitsuru Funakoshi - PPT Presentation

Yuto Nakashima Shunsuke Inenaga Hideo Bannai Masayuki Takeda Kyushu University Computing Maximal Palindromes and Distinct Palindromes in a Trie Palindromes A palindrome is a string that reads the same forward and backward ID: 814568

trie palindromes maximal root palindromes trie root maximal distinct algorithm number time pals string edge space working group extended

Share:

Link:

Embed:

Download Presentation from below link

Download The PPT/PDF document "PSC2019 Mitsuru Funakoshi" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

PSC2019

Mitsuru Funakoshi, Yuto Nakashima, Shunsuke Inenaga, Hideo Bannai, Masayuki TakedaKyushu University

Computing

Maximal Palindromes and

Distinct Palindromes in a Trie

Slide2

Palindromes

A palindrome is a string that reads the same forward and backward.Examples○ radar

neveroddoreven (Never odd or even.)○リモコンてんこもり (りもこんてんこもり) = There are a lot of remote controllers.○

 

Slide3

Palindromes

A palindrome is a string that reads the same forward and backward.Examples○ radar

neveroddoreven(Never odd or even.)○ In this talk, we consider maximal / distinct palindromes in a trie (rooted edge-labeled tree).I will begin with maximal / distinct palindromes in a string.

 

Slide4

Let

be a string of length .For each integer / half-integer position

in

,

the maximal substring of that is a palindrome with center is the maximal palindrome centered at . E.g.)

cbabcaaaccacbabcab

The number of maximal palindromes in any string

of length

is

exactly

(including empty strings)and all of them can be computed in time [Manacher, 1975].

 

7

9.5

Maximal palindromes in a string

Slide5

For a string , let

be the set of all distinct palindromes in .E.g.)

cbabcaaaccacbabcab

{ε,a,b,c,aa,cc,aaa,bab,cac,acca, cbabc,caaac,acbabca}

 

Distinct palindromes in a string

Slide6

For a string , let

be the set of all distinct palindromes in .E.g.)

cbabcaaaccacbabcab

{ε,a,b,c,aa,cc,aaa,bab,cac,acca, cbabc,caaac,acbabca}

 

Distinct palindromes in a string

Slide7

For a string , let

be the set of all distinct palindromes in .E.g.)

cbabcaaaccacbabcab

{ε,a,b,c,aa,cc,aaa,bab,cac,acca, cbabc,caaac,acbabca}

The maximum number of distinct palindromes in any string

of length

is at most

[Droubay et al., 2001].

All of them can be computed in time [Groult et al., 2010].

 

Distinct palindromes in a string

Slide8

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

A trie is a rooted tree where each edge is labeled by a single char and

out-going edges of each node are labeled by mutually distinct chars.

A trie is a natural extension to a string,

and is a compact representation of a set of strings.

Trie

Slide9

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Input: a

trie

(rooted edge-labeled tree) with

edges

Output:

all

maximal palindromes

in

all

distinct palindromes

in

 

Problem

Slide10

Pals in a trie (rooted edge-labeled tree)

only consider paths in the root-to-leaf direction

a

a

b

c

c

a

d

a

bcc

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide11

Pals in a trie (rooted edge-labeled tree)

only consider paths in the root-to-leaf direction

a

a

b

c

c

a

d

a

bc

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide12

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Pals in a trie (rooted edge-labeled tree)

only consider paths in the root-to-leaf direction

Slide13

The maximal palindrome centered at is

bccaaccb.

Maximal palindromes in a trie

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide14

The maximal palindrome centered at is aaa

.Maximal palindromes in a trie

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide15

Distinct palindromes in a trie

a

a

b

c

c

a

d

a

b

cc

c

b

a

b

b

c

a

b

b

a

a

c

root

For a trie

, let

be the set of all distinct palindromes in

.

{

ε,a,b,c,d,aa,bb,cc,aaa,cdc,acca

,

bccb,caac,cbbc,abccba,ccaacc,bccaaccb

}

 

Slide16

Distinct palindromes in a trie

a

a

b

c

c

a

d

a

b

cc

c

b

a

b

b

c

a

b

b

a

a

c

root

For a trie

, let

be the set of all distinct palindromes in

.

{

ε,a,b,c,d,aa,bb,

cc

,aaa,cdc,acca

,

bccb,caac,cbbc,abccba,ccaacc,bccaaccb

}

 

Slide17

Distinct palindromes in a trie

a

a

b

c

c

a

d

a

b

cc

c

b

a

b

b

c

a

b

b

a

a

c

root

For a trie

, let

be the set of all distinct palindromes in

.

{

ε,a,b,c,d,aa,bb,

cc

,aaa,cdc,acca

,

bccb,caac,cbbc,abccba,ccaacc,bccaaccb

}

 

Slide18

Naïve methods for these problems

All maximal (distinct) pals can be computed by naïvely applying Manacher’s (Groult et al.’s) algorithm to each root-to-leaf path.This takes

time for each root-to-leaf path,

where

is the height of the trie. 

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide19

Naïve methods for these problems

Therefore this naïve method computes all maximal / distinct palindromes in a trie in time,

where

is the number of leaves.

This requires time in the worst case.  

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide20

Main results for maximal palindromes

# outputs

Time

Working space

In a trie

Algorithm 1

Algorithm 2

In a string

Manacher

# outputs

Time

Working space

In a trie

Algorithm 1

Algorithm 2

In a string

Manacher

: the length of

the

string

: the number of edges of the trie

: the number of leaves of the trie

: the height of the trie

: the number of the branching nodes of the trie

 

Slide21

Main results for maximal palindromes

# outputs

Time

Working space

In a trie

Algorithm 1

Algorithm 2

In a string

Manacher

# outputs

Time

Working space

In a trie

Algorithm 1

Algorithm 2

In a string

Manacher

: the length of

the

string

: the number of edges

of the trie

: the number of leaves of the trie

: the height of the trie

: the number of the branching nodes of the trie

 

These time complexity are

in the worst case.

 

Slide22

# outputs

Time

Working space

In a trie

In a string

Groult et al.

# outputs

Time

Working space

In a trie

In a string

Groult et al.

Main results for distinct palindromes

: the length of a string

: the number of edges

of the trie

: the height of the trie

 

Slide23

In a trie

# outputs

Time

Working space

Maximal pals

Algorithm 1

Algorithm 2

Distinct

pals

In a trie

# outputs

Time

Working space

Maximal

pals

Algorithm 1

Algorithm 2

Distinct

pals

Main results

: the number of edges

of the trie

: the number of leaves of the trie

: the height of the trie

: the number of the branching nodes of the trie

 

Slide24

In a trie

# outputs

Time

Working space

Maximal pals

Algorithm 1

Algorithm 2

Distinct

pals

In a trie

# outputs

Time

Working space

Maximal

pals

Algorithm 1

Algorithm 2

Distinct

pals

Main results

: the number of edges

of the trie

: the number of leaves of the trie

: the height of the trie

: the number of the branching nodes of the trie

 

Slide25

The number of maximal palindromes

a

a

b

c

c

a

d

a

b

cc

c

b

a

b

b

c

a

b

b

a

a

c

root

 

Slide26

The number of maximal palindromes

 

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide27

The number of maximal palindromes

 

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide28

The number of maximal palindromes

 

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide29

The number of maximal palindromes

 

There is exactly one maximal palindrome for each center pos

,

since the reversed path from to the root is unique and the out-going edges of each node are labeled by mutually distinct characters.Because there are

center positions in a trie,

the number of maximal palindromes in a trie is also

.

 

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide30

In a trie

# outputs

Time

Working space

Maximal pals

Algorithm 1

Algorithm 2

Distinct

pals

In a trie

# outputs

Time

Working space

Maximal

pals

Algorithm 1

Algorithm 2

Distinct

pals

Computing maximal palindromes

: the number of edges

of the trie

: the number of leaves of the trie

: the height of the trie

: the number of the branching nodes of the trie

 

Slide31

For each edge

in a depth-first traversal on the trie: Check whether all suffix palindromes of the root-to-

path

can be extended with edge

or not.If all out-edges from have been processed,output all palindromes ending at

that did not extend

with any path, as maximal palindromes.

If

is a leaf,

output all palindromes ending at

, as maximal palindromes. Overview

Slide32

For each edge

in a depth-first traversal on the trie: Check whether all suffix palindromes of the root-to-

path

can be extended with edge

or not. Step 1

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

 

 

Slide33

For each edge

in a depth-first traversal on the trie: Check whether all suffix palindromes of the root-to-

path

can be extended with edge

or not. Step 1

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

 

 

Slide34

For each edge

in a depth-first traversal on the trie: Check whether all suffix palindromes of the root-to-

path

can be extended with edge

or not. Step 1

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

 

 

Slide35

For each edge

in a depth-first traversal on the trie: Check whether all suffix palindromes of the root-to-

path

can be extended with edge

or not. Step 1

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

 

 

Slide36

If all out-edges from

have been processed,output all palindromes ending at that did not extend

with any path, as maximal palindromes.

 

Step 2

Maximal palindrome

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

 

 

Slide37

There are

suffix palindromes ending at each node. But we can process them in a total of

time and

working space for all nodes,

by using periodic structures of suffix palindromes. Suffix palindromes ending at each node

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide38

 

 

 

 

 

 

 

Position

 

Periodic property of suffix pals in a str.

Lemma 1 [Apostolico et al., 1995]

Suffix palindromes in a string which end at

pos

can be classified into

groups

such that each pal in the same group has the

same smallest period.

 

All groups can be represented in

space.

 

Slide39

The maximal palindromes in a group except for the longest one are immediately preceded by the same character,

since these palindromes have same smallest period.

root

 

 

 

Immediately preceding chars for each group

Slide40

The maximal palindromes in a group except for the longest one are immediately preceded by the same character.

Therefore, the number of distinct immediately preceding characters for each group is at most 2.

b

b

root

 

 

b

b

 

 

Immediately preceding chars for each group

Slide41

b

bb

b

Let

be the immediately preceding character of the longest one.Let be the immediately preceding character of the others.Let be the label of edge (

.

 

Extension of each group

root

 

c

 

 

Slide42

b

bb

b

There are 4 cases to consider for each group:

(1) (2) ,

(3)

,

(4)

,

 

Extension of each group

root

 

c

 

 

Slide43

 

(1)

All these palindromes are extended.

 Extension of each group

root

 

c

 

b

b

b

b

Slide44

b

bb

b

(2)

, The longest one is extended. (Other palindromes might be extended with another out-edge of

.)

 

Extension of each group

root

 

c

 

 

Slide45

b

b

b

b

(3)

,

All these palindromes but the longest one are extended.

(The longest one might be extended with another out-edge of

.)

 Extension of each group

root

 

c

 

 

Slide46

b

bb

b

(4)

, All these palindromes are not extended with this edge

. (These palindromes might be extended with another out-edge of

.)

 

Extension of each group

root

 

c

 

 

Slide47

We represent each group by an arithmetic progression,

so each group can be processed in time in the above all cases. There are

arithmetic progression at each node,

therefore we can check whether suffix palindromes

can be extended or not in time per each node.

Since there are

nodes,

we can compute all maximal palindromes in

time.

 

Running time

Slide48

Since suffix palindromes that are not extended with edge

might be extended with another path, we have to store them during traversal from

to all children of

.

These palindromes are maximal in the root-to- path, so the working space is during traversal.  Working space

 

 

a

a

b

c

c

a

d

a

b

c

c

c

b

a

b

b

c

a

b

b

a

a

c

root

Slide49

Summary

In a trie

# outputs

Time

Working space

Maximal pals

Algorithm 1

Algorithm 2

Distinct

pals

In a trie

# outputs

Time

Working space

Maximal

pals

Algorithm 1

Algorithm 2

Distinct

pals

Slide50

Open problems

Can we compute maximal / distinct pals in a trie in time?

Can we efficiently compute maximal / distinct pals in an unrooted tree?

The maximum number of distinct pals in an unrooted tree

is [Brlek et al., 2015]+[Gawrychowski et al., 2015].Can we efficiently compute runs / squares in a trie / an unrooted tree?The maximum number of distinct squares in an unrooted tree

is

[Crochemore et al., 2012] and all of them can be

counted in

time [

Kociumaka

et al., 2014]. The maximum number of runs in a trie is less than and

all of them can be computed in

time

[

Sugahara

et al., 2019].

 

Slide51

Can we generalize

Manachr’s algorithm? a

b

a

aaccb

c

b

b

c

a

root

Slide52

Can we generalize

Manachr’s algorithm? ab

c

a

accb

c

b

b

c

a

root

Slide53

Previous work of palindromes in a tree

Theorem [Brlek et al., 2015] The maximum number of distinct palindromes in an unrooted tree is

.

 

Theorem [Gawrychowski et al., 2015] The maximum number of distinct palindromes in an unrooted tree is .

 

To our knowledge, palindromes in a

trie

(rooted edge-labeled tree)

have not been studied previously

.There is previous work on the number of distinct palindromes in an unrooted tree with edges. 

Slide54

 

 

 

 

 

 

 

Periodic property of maximal palindromes

Each group can be represented by

an arithmetic progression.

Each arithmetic progression is

a tuple

representing the sequence

with common difference

.

 

 

 

 

Position

 

Slide55

a

bb

a

a

cabba

a

b

a

b

a

c

a

b

a

a

a

b

c

Strategy of Algorithm 2

Slide56

a

bb

a

a

cabba

a

b

a

b

a

c

a

b

a

a

a

b

c

Strategy of Algorithm 2

Slide57

a

bb

a

a

cabb

a

a

b

a

b

a

c

a

b

a

a

a

b

c

 

 

Strategy of Algorithm 2

Slide58

 

 

 

 

a

b

b

a

a

c

a

b

b

a

a

b

a

b

a

c

a

b

a

a

a

b

c

Strategy of Algorithm 2

Slide59

a

b

b

a

acab

b

a

a

b

a

b

a

c

a

b

a

a

a

b

c

 

 

 

 

Strategy of Algorithm 2

Slide60

a

b

b

a

acabb

a

a

b

a

b

a

c

a

b

a

a

a

b

c

 

 

 

 

Strategy of Algorithm 2

Slide61

a

b

b

a

acabb

a

a

b

a

b

a

c

a

b

a

a

a

b

c

 

 

 

 

 

Strategy of Algorithm 2

Slide62

a

bb

a

a

cabba

a

b

a

b

a

c

a

b

a

a

a

b

c

Strategy of Algorithm 2

Slide63

All maximal palindromes can be computed by the above operation.

a

b

b

aacab

b

a

a

b

a

b

a

c

a

b

a

a

a

b

c

Strategy of Algorithm 2

Related Contents


Next Show more