• No results found

Fast algorithms to generate restricted classes of strings under rotation

N/A
N/A
Protected

Academic year: 2021

Share "Fast algorithms to generate restricted classes of strings under rotation"

Copied!
106
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

INFORMATION TO U S E R S

This manuscript has been reproduced from the microfilm master. UMI films

the text directly from the original or copy submitted. Thus, some thesis and

dissertation copies are In typewriter ^ c e , while others may be from any type of

computer printer.

The quality of this reproduction is dependent u p o n th e quality of th e

copy submitted. Broken or indistinct print, colored or poor quality illustrations

and photographs, print bleedthrough, substandard margins, and improper

alignment can adversely affect reproduction.

In the unlikely event that the author did not send UMI a complete manuscript

and there are missing pages, these will be noted.

Also, if unauthorized

copyright material had to be removed, a note will indicate the deletion.

Oversize materials (e.g., maps, drawings, charts) are reproduced by

sectioning the original, beginning at the upper left-hand comer and continuing

from left to right in equal sections with small overlaps.

Photographs included in the original manuscript have been reproduced

xerographically in this copy.

Higher quality 6" x 9* black and white

photographic prints are available for any photographs or illustrations appearing

in this copy for an additional charge. Contact UMI directly to order.

Bell & Howell Information and Learning

300 North Zeeb Road, Ann Arbor, Ml 48106-1346 USA

800-521-0600

(2)
(3)

Fast Algorithms to G enerate Restricted Classes of Strings

Under Rotation

by

J o s e p h J a n i e s Sawacl a B . S c . , U n i v e r s i t y o f \ ’i c l o ri a . 199G

A Di ss e r t at i o n S u b m i t t e d in I’artial F uHi l l ni ent o f t h e R e q u i r e m e n t s for t he D e g r e e o f D O C T O R O F I M I I L O S O I T I V in t h e D e p a r t m e n t o f C o m p u t e r S c i e n c e We a c c e p t t h i s d i s s e r t a t i o n as c o n f o r m i n g t o t h e requi red s t a n d a r d Dr. Fr ank R us k e v. S u p e r v i s or ( D e p a r t m e n t o f C o m p u t e r S c i e n c e Dr. M i c a e l a StVra. D e p a r t m e n t a l M e m b e r ( D e p a r t m e n t o f C o m p u t e r S c i e n c e I Dr. V a l e r i e K i n g . D e p a x L o i e n t a i ' l t l e m b e r ( D e p a r t m e n t o f C o m p u t e r Sci enci

Dr. D o b .\liers. O u t s i d e M e m b e r ( De par t nient o f M a t h e m a t i c s |

---•. C ar l a S a v a g e . F x t e r n m E x a m i n e r Dr. C ar l a S a v a g e . ExternKl E x a m i n e r ( D e p a r t m e n t o f C o m p u t e r S c i e n c e . .N'orth C a r o l i n a S t a t e U n i v e r s it y) © J o s e p h J a m e s S a w a d a . 2U00 U n i v e r s i t y o f V i c t o r i a

A l l r i ght s r e s er v ed. Thi s d i s s e r t a t i o n m a y n o t hi r t p r o d u c t d in i rhol r o r in p a r t , b y p h o t o c o p y i n y o r o t h e r m e a n s , wi t ho ut the pe nni . s s t o n o f t i n a u t h o r .

(4)

S u p e r v i s o r : Dr. Frank R u s k e y

A B S T R A C T

A n e c k l a c e is a r e p r e s e n t a t i v e o f a n ec[ n i v a l e n e e c l as s o f A-ary s t r i n g s u n d e r r o t a t i o n .

E f fi ci e n t a l g o r i t h m s for g e n e r a t i n g ( i e. . l i s t i n g ) n e c k l a c e s h a v e b e e n k n o w n for s o m e

t i m e . .Many a p p l i c a t i o n s , h o w e v e r , rec[uire a r e s t r i c t e d c l ass o f n e c k l a c e s for w h i c h

n o ef f i c i e nt g e n e r a t i o n a l g o r i t h m p r e v i o u s l y e x i s t e d . T h i s d i s s e r t a t i o n addre ss( ' s t his p r o b l e m bv d e v e l o p i n g fast a l g o r i t h m s t o g e n e r a t e t h e f o l l o w i n g r e s t r i c t e d clas.ses o f n e c k l a c e s : ( a ) u n l a b e l e d n e c k l a c e s , ( b) fi xed d e n s i t y n e c k l a c e s , ( c ) n e c k l a c e s win're t h e n u n d ) e r o f e a c h a l p h a b e t s y m b o l is fi xe d, ( d ) c ho r d d i a g r a m s . (<') n e c k l a c e s w h i c h a v o i d a p a r t i c u l a r L y n d o n s u b s t r i n g , a n d ( f ) b r a c e l e t s . ,-\n a n a l y s i s for e a c h a l g o r i t h m ( a ) , ( b ) . ( e ) . a n d ( f ) s h o w s t h a t t h e a m o u n t o f c o m p u t a t i o n is p r o p o r t i o n a l t o t h e n u m b e r o f s t r i n g s p r o d u c e d . E x p e r i m e n t a l r e s u l t s g i v e a s t r o n g i n d i c a t i o n t h a t t h e a l g o r i t h m s for (c) a n d ( d ) a l s o a c h i e v e t hi s t i m e b o u n d . In a d d i t i o n , a n e w f h n i v a t i o n

ol t h e k n o w n t o r m u l a lor c o u n t i n g c ho r d d i a g r a m s is preseut i ' d. a l o n g w i t h a linear

t i m e a l g o r i t h m to g e n e r a t e a basis for t h e /;-th h o m o g e n e o u s c o m p o n e n t o f t h e free

Lie a l g e b r a . E x a m i n e r s : Dr. Fr a n k R u s k e y . S u p e r v i s o r ( D e p a r t m e n t o f C o m p u t e r S c i e n c e ) Dr. M i c a e l a Surra. D e p a r t m e n t a l M e m b e r ( D e p a r t m e n t o f C o m p u t e r S c i e n c e Dr. V a l e ri e K i n g , Ef epanstmentjj/ . Member ( D e p a r t m e n t o f C o m p u t e r S c i e n c e Dr. B o b .Miers. O u t s i d e M e m b e r ( D e p a r t m e n t o f M a t h e m a t i c s )

r. C a r l a S a v a g e . External <E. xami r

Dr . C a r l a S a v a g e . E x t e r n a l ( E x a m i n e r ( D e p a r t m e n t o f C o m p u t e r S c i e n c e . N o r t h C a r o l i n a S t a t e f University)

(5)

I l l

C ontents

C o n t e n t s

v

L is t o f T a b l e s

vi

L is t o f F i g u r e s

viii

A c k n o w l e d g e m e n t s

ix

D e d i c a t i o n

x

1

I n t r o d u c t i o n

1

2

B a c k g r o u n d

5

■J.l Phi a n d m i l ... ) 2 . 2 Buni s i de' . s l e m m a ... () 2. ) N e c k l a c e s . L y n d o n wo r d s , a n d p r e - n e c k l a c e s ... 6 2.3.1 r e ci i rs i xe n e c k l a c e g e n e r a t i o n a l g o r i t h m ... 8

3

U n l a b e l e d N e c k l a c e s

11

3.L B a c k g r o u n d ... II 3 . 2 G e n e r a t i n g b i n a r y u n l a b e l e d n e c k l a c e s ... 12 3 . 3 . A n a l y s i s ... 16

4

F ixed D en sity N ecklaces

17

4.1 B a c k g r o u n d ... 17

(6)

I V Mof l i f i e d tKH'klai’t ' a l g o r i t h m ... 19 -1.2.2 Fi.\(’cl ( l o n s i t y iK'c-klaco a l g o r i t h m ... 21 -1.3 . - V n a l y s i s ... 23 L I .Another a l g o r i t h m ... 32 -1.5 .An a p p l i c a t i o n ... 31 5 F i x i n g t h e N u m b e r o f e a c h A l p h a b e t S y m b o l 3 6 5.1 B a c k g r o u n d ... 3(1 5 . 2 .A s i mp l e a l g o r i t h m ... 37 5 . 3 .A last a l g o r i t h m ... 3S 5.3.1 A n e w c a n o n i c a l f o r m ... 38 5.3.2 A v e r i f i c a t i o n a l g o r i t hm ... 39 5.3.3 A g e n e r a t i o n a l g o r i t h m ... 11 6 C h o r d D i a g r a m s 4 3 ti.l B a c k g r o u n d ... 13 Ü.2 E n u m e r a t i n g n o n - i s o m o r p h i c c h o r d d i a g r a m s ... 11 ().3 Re p r es e n t i n g c h o t f l i l i a g r a m s ... 17

ti.l A sim[)le al gorit h n i ... 18

(i. 1.1 . A n a l y s i s ... 19 li.5 .A fast a l g o r i t h m ... 51 (i.5.1 Ge nPos ( . s . f . / ; . r . / u . s f ) ... 52 fi.5.2 G e n P o s 2 ( s , t . p . / ) ' . c . p n r O ... 53 (i.5.3 Ge nRest ( . s. f . r ) ... 5-1 ( i . 5 . 1 . - \ n a l y s i s ... 51 7 F o r b i d d e n S u b s t r i n g s 5 7 7.1 B a c k g r o u n d ... 58 7.1.1 T h e a u t o m a t a - b a s e d s t r i n g m a t c h i n g a l g o r i t h m ... 59 7. 2 . A l g o r i t h m s ... (iO 7.2.1 G e n e r a t i n g A-ary s t ri ng s w i t h f o r b i d d e n s u b s t r i n g s ... 60

(7)

7. 2 . 2 G e n e r a t i n g A-ary ci rcul ar s t r i n g s w i t h f o r b i d d e n s u i ) st r i n g s . . ()2

7.2.:) G e n e r a t i n g A--ary n e c k l a c e s w i t h f or bi dde n s u b s t r i n g s ... til

7.:) . Analysis o f t h e . A l g o r i t h m s ... (id 7.:). 1 S t r i n g s ... dd 7.:).2 Ci rc ul a r s t r i n g s ... d8 7.:).:) N e c k l a c e s ... 70

8

B r a c e l e t s

73

8.1 B a c k g r o u n d ... 7:5 8 . 2 G e n e r a t i n g B r a c e l e t s ... 71 8.:5 F o r bi d d e n s u b s t r i n g s ... 70 8.1 . A n a l y s i s ... 81

9

L y n d o n B r a c k e t s

86

0.1 B a c k g r o u n d ... Mi 0 . 2 G e n e r a t i n g L y n d o n b r a c k e t s ... 87 0 . 5 . A n a l y s i s ... 00

10 C o n c l u s i o n

91

10.1 ( o n t r i b u t i o n s ... 01 10.2 F u t u r e w o r k ... 02

B i b l i o g r a p h y

93

(8)

V I

List o f Tables

) Dilfcri'iit ol ) jo c t s out[)ut l)V ditFoRMit v e r s i o n s o f P r i n t i t ... I)

Ô.I Kxpi'rinuMital re'sults for Simpl eFi xeAl ph(/ . / ) ] ...

Ô.2 A n «‘( [ui v a l e nc e c la ss i l l n s t r a t i n g the J s t r i n g s ...

6.1 H.xperi ni enl al r e s ul t s for

SimpleChords(/./

j

1 ...

-30 6 . 2 Lvxperitneni al re s ul t s for

FastChords(

/ / 1 ... -36

(9)

v u

List o f Figures

2.1 Th<' rcci i rsi Vf n c rk i a c i’ al<>oril h m ... N

2 . 2 Co i n p u t a t i D i i rrc f for .\%| I) f r o m N e c k l a c e ! / . /M ... 11)

•'5.1 l ’ iilal)('lf<l hiiiary i i f c k l a c f alsTorithm ... l(i

-1.1 ( ' o m p u t a l i o n t r f f for .\ ji t) f r o m M o d i f i e d N e c k ( / . / j ) ... 1.2 .Moditifd i i f f k l a c f algorit l i m ... 21 l.d C o m p u t a t i o n t r re ( s o l id t’d g e s o n l y ) for . \ j ( 7 . d ) f rom F i x e d D e n s i t y ( / . /)) 2d 1.1 Fi.Kfd d f i i s i t y u f c k l a r f a l g o r i t h m ... 21 1.5 . Al gori t hm for g e n e r a t i n g n e c k l a c e s w i t h q z e r o s ... M 5.1 s i m p l e a l g o r i t h m t o g e n e r a t e

N (

u,). n , n c - i )

...

57 ti.l C h o r d d i a g r a m w i t h I c h o r ds ... 11

(i.2 ( a) O n e o f t h e 2ii — p p o s s i b l e l e n g t h s for t h e c h o r ds s t a r t i n g at

pq. ( b ) [•or p e v e n , t h e r e is o n l y o n e c h o i c e for t h e e n d p o i n t latulitig ba c k in t h e list (/. 2f/ p q ... -16 6. d T w o s t r i n g r ep r e s e n t a t i o n s : ( a ) l a be l c h o r d s t h e n v e r t i c e s (K) l abel v e r t i c e s by c h o r d l e n g t h ... -16 6.-1 .A s i n i [ d e a l g o r i t h m for g e n e r a t i n g n o n - i s o m o r p h i c c ho r d d i a g r a m s w i t h n c h o r d s ... 50 6 . 5 .A fast a l g o r i t h m for g e n e r a t i n g n o n - i s o m o r p h i c c h o r d d i a g r a m s w i t h n c h o r d s ... 5 2 6 . 6 G e n P o s { s J . p . i \ l a s t ) ... 53

(10)

V I I I

6 7 G e n P o s 2 ( r p a r t ) ... In

6. 8 GenRe s t ( . s. r. r I ... .16

7.1 .An al gorit Inn For g e n e r a t i n g A'-ary .strings w i t h no s u b s t r i n g e q u a l t o / 61 7. 2 P r o c e d u r e used t o s e t t h e values o f t n a t r h ( i . t ) ... (id 7 d F u n c t i o n used to te st t h e wr ap a r ou n d o f c i r c ul a r stritigs ... (id 7. 1 . \ i i a l g o r i t h m For g e n e r a t i n g A-ary c i r c u l a r ->lriug.', w i t h no s u i i s t r i u g e q u a l to / ... 61

7.Ô .An algorirlitn For g e n e r a t i n g A-ary n e c k l a c e s w i t h no s u b s t r i n g e q u a l to / 8.1 . \ e c k l a c ( ' s aiul l i r a c e l e t s ... 71

S.J b r a c e l e t g e n e r a t i o n a l g o r i t h t u ... 78

I).I T h e L y nd o n b r a c k e t s oF L j ( 6 ) ... 87

').d A Function to print t h e b r a c k e t s oF a L y n d o t i w o r d ... 88

D.d T h e val ues .■>plil(!.j) For t h e I.yndoti w o r d 0 0 1 0 0 1 0 1 1 ... 88

(11)

IX

A cknow ledgem ents

1 w o u l i l l ike t o t h a n k Frank R u s k e y for all t ha t he has t a u g h t m e . for his g u i d a n c e , for

his l i n a u c i a l s u p p o r t , a n d for b e i n g a g o o d guy. 1 c a n no t i m a g i n e a b e t t e r s t n d e n t -

s i i p e r v i s o r r tdati onshi p.

1 w o u l d al so like t o t h a n k m y c o m m i t t e e ami e x t e r n a l e x a m i n e r , a l o n g w i t h t h e

e n t i r e < o m | ) u t e r s c i e n c e d e p a r t m e n t ( e s p e c i a l l y t he o t l i c e s t a l f ) here at t h e I ' n i v e r s i t y

o f V i c t o r i a for thei r s u p p o r t .

M y r es e ar ch has b e e n s u p p o r t e d in part by X a t n r a l S c i e n c e s and E n g i n e e r i n g

(12)
(13)

C hapter 1

Introduction

riit' rapi d g r o w t h in tli<' Holds o f ( • onihiiiatorial clioi i i i st rv a n d c o n i p n t a t i o n a i b i o l o g y

IS rt'snl l i ng in an inoroasod do i na i id for olficdont a l g o r i t h i n s w h i c h p r o d u c o o x h a i i s t i v o

lists o f c o m b i n a t o r i a l o b j e c t s [:5], D a n ( Inslioht ( s e e [I ij. pg. x v | c l a i m s t h a t "signili-

cant c o n t r i b u t i o n s to c o m p u t a t i o n a l b i o l o g y m i g h t bo m a d e by e x t o n d i n g o r a d a p t i n g

[string] a l g o r i t h m s f rom c o m p n t o r s c i e n c e , e v e n w h e n t h e o r i g i na l a l g o r i t h m h a s no

c l e a r u t i l i t y in bi ol ogy. " In p a r t ic u l a r , c o r r e s p o n d e n c e s b e t w e e n D . \ . \ s e c | u e n c e s a n d

r e s t r i c t e d c l a s s e s o f ci r c ul ar stritigs are d e s c r i b e d in i7|.

W i t h i n t h e m a t h e m a t i c a l s c i e n c e s , r e s e ar ch e rs are c o n s t a n t l y t r y i n g t o l i n d p a t ­ t e rn s h i d d e n in t h e s t r u c t u r e o f c o m b i n a t o r i a l o b j e c t s . T h e g r o w i n g t r e n d o f u s i n g c o m p u t e r s an d a l g o r i t h m s t o p r o d u c e l ists o f s u c h o b j e c t s is a l l o w i n g r e s e a r c he r s t o o b t a i n m o r e i n f o r m a t i o n a b o u t t h e o b j e c t s t h e m s e l v e s . O f t e n , t h i s will l ead t o a m o r e rhoroi t gh u t i d e r s t a t i d i n g o f an o b j e c t w h i c h m a \ lead t o n e w a n d i n t e r e s t i n g d i s c o v ­ e ri es. In s o m e c a s e s , a l g o r i t h m s w h i c h p r o d i t c e e x h a u s t i v e l ist s c a n be u s e d t o p r o v e t h e e x i s t e n c e o f a r e l a t e d o b j e c t . For e x a m p l e , t h e ti.xed d e n s i t y n e c k l a c e a l g o r i t h t u o u t l i n e d in C h a p t e r 4 is u s e d to pr ov e t h e e x i s t e n c e o f a ( 1 3 1 . 1 3 ) d i f f e r e n c e c o \ e r ( s e e C h a p t e r 4. 5) .

.An i m p o r t a n t c o n s i d e r a t i o n for a n y a l g o r i t h m is its r u n n i n g t i m e . For g e n e r a t i o n

a l g o r i t h m s , t h e u l t i m a t e p e r f o r m a n c e g o a l is a n a l g o r i t h t u w i t h c o m p u t a t i o n p r o p o r ­

t i o n a l t o t h e n u m b e r o f o b j e c t s g e n e r a t e d ( w h e r e t h e c o m p u t a t i o n reflects t h e t o t a l

(14)

o bj e ct ). S u c h a l g o r i t h m s arc s a i d t o b e C A T . for C o n s t a n t .Amort i zed T i m e .

S t r i n g s w i t h e q u i v a l e n c e u n d er r o t a t i o n are o n e o f t h e m o s t f u n d a m e n t a l t y p e s

of c o m b i n a t o r i a l o b j e c t . Suc h o b j (' c t s . m o r e c o m m o n l y k n o w n as in rfclart ar i s e

n a t ur a l ly in m a n v areas i n c l u d i n g k n o t theory, c ol or p r i n t i n g . D.\.A s e ( | u e n c i n g a n d

the t h e o r y o f free Lie al gebras. . Al g o r i t hms for g e n e r a t i n g n e ck l ac e s a n d L y n d o n

words ( a p e r i o d i c n e c k l a c e s ) we r e (irst d e v e l o p e d by F r e d r i c k s o n and Ke s s l er 110] arul

Fredricksen a n d Mai orai i a [ l l j . T l u ' s e a lg o r i t ht ns w e r e p r o v e n t o he C.A 1 by R u s k e y .

Savage a m i W a n g ['Jlj. re c ur s i ve v e r s i o n ol t h e s e a l g o r i t h m s is o ut l i t i e d in ['iOj.

M a n y a p p l i c a t i o n s d o not r e qui r e all neckl ace s , but i n s t e a d o n l y t h o s e s a t i s f y i n g a

par t i cul ar r e s t r i c t i o n . Pr e v i o u s t o t h i s d i s s e r t a t i on , n o e f f i c ie nt a l g o r i t h m w a s k n o w n

to g e n e r a t e a n v o f t h e f ol l owi ng r e s t r i c t e d cl asses o f n e c k l a c e s :

• n n l a b e h ' d n e ck l a c e s .

• lixeil ( hu i s i t y necklace’s.

• n e c k l a c e s w h e r e t he n u m b e r o f e a c h al jdi abet s y m b o l is fixed.

• c h o r d d i a g r a m s .

• n e c k l a c e s w i t h forliiilden s u b s t r i n g s , or

• b r a c e l e t s .

.A bri e f d e s c r i p t i o n o f e ac h o b j e c t f o l l ows .

l ’i i l nbrl cd nccA/ucr.\ are n e c k l a c e s w i t h e q u i v a l e n c e u n d e r p e r m u t a t i o n o f t h e al ­

p h a be t s y m b o l s . In t h e b i n a ry c a s e , t h e y ha v e a p p l i c a t i o n in t h e g e n e r a t i o n o f irre­ d u c i b l e p o l y n o m i a l s ove r G F ( 2 ) [6|. N o a l g o r i t h m h a s b e e n p r e v i o us l y p u b l i s h e d to g e n e r a t e i m l a b e l e d n e c k l a c e s , e v e n in t h e bi nary c as e . F i x n l ( l ( us i t i ) ntck-ldct '^ are n e c k l a c e s w h e r e t h e n u m b e r o f n o n - z e r o c h a r a c t e r s , or t he d e n s i t y , is fi xe d. P r e v i o u s f i xe d d e n s i t y n e c k l a c e a l g o r i t h m s ha ve r u n n i n g t i m e s o f 0 ( n ■ . \ ( n . c l ) ) ( W a n g a n d S a v a g e [28]) a nd 0 ( . V ( n ) ) ( F r e d r i c k s e n a n d K e s s l e r [10]). w he r e . \ ' ( n . d ) d e n o t e s t h e n u m b e r o f ne c kl ac e s w i t h l e n g t h n and d e n s i t y d a n d . V(n) d e n o t e s t h e n u m b e r o f n e c k l a c e s w i t h l e n g t h n. W a n g a n d S a v a g e b a s e t h e i r a l g o r i t h m o n f i n d i n g a H a m i l t o n c y c l e in a g r a p h r e l a t e d t o a tr ee o f n e c k l a c e s . T h e m a i n f e a t u r e o f t h e i r a l g o r i t h m is t h a t it also g e n e r a t e s t h e s t r i n g s in G r a y c o d e o r d e r.

(15)

T h e bas i s o f F re d r i ck s e n a n d Ke s s l er ' s a l g o r i t h m is a m a p p i n g o f l e x i c o g r a p h i c a l l y

o r d e r e d c o m p o s i t i o n s t o n e c k l a c e s . B o t h a l g o r i t h m s c o n s i d e r o n l y bi n a r y neckl aces.

. Another n ’s t r i c l e d c l as s o f n e c k l a c e s are t h o s e w h e r e t h e n u m l x ' r o f each alphal i et

s y m b o l is ti.xed. S u c h s t r i n g s are p r o m i n e n t in c y c l i c a r r a n g e m e n t s [ Ij. and also arisf'

in t h e g e n e r a t i o n o f p o l y g o n s - w h e r e e a c h a l p h a b e t s y m b o l r e p r e s e n t s a dire ct i on:

n o r t h , e a s t , s o u t h , a n d w e s t . In t h e b i n a r y c a s e , t h e s e s tr i n g s ar e e qu i v a l e nt to fixed

d e n s i t y n e c kl a c e s . In t h e g e n e r a l c as e , no fast g e n e r a t i o n a l g o r i t h t u was p r e v i ou s ly

kt i own.

C h o r d d i a g r a m s c a n b e r e p r e s e n t e d by l eitgth '2ii u n l a b e l e d ne c kl ac e s over an

a l p h a b e t o f s i z e n. w h e r e t he r e are e x a c t l y t w o o c c u r r e n c e s o f e a c h a l p h a b e t s y m b o l .

C h o r d d i a g r a m s h a v e a p p l i c a t i o t i iti t h e cot it e x t o f X’a s s i li e v i n v a r i a n t s , which in tur n

h a v e a p p l i c a t i o n in k not t h e o r \ [2j. .A r e l a t e d o b j e c t c al le d a l i n e a r i z e d chord d i a g r a m

is Stttdied bv S t o i m e n o w iti [’J l j . a n d b r ai de d c ho rd diagrattis are d i s c u s s e d by Birtuaii

a n d 1 r app in [oj. M u c h a t t e n t i o t i has b e e n p l a c e d on tin' e t i u t ne r a t io n o f c hor d

d i a g r a t n s . but no get i erat i ot i a l g o r i t h m s h a v e b e e n pr c v i oi ts l y p u b l i s h e d .

. Necklaces w i t h f o r bi d d e n s u b s t r i n g s a r e a n o t h e r r e st r i c t ed c l a s s o f necklaces. If

t h e f or bi d d e n s u b s t r i n g is O', theti a s i m p l e m o d i f i c a t i o n t o t h e r ecurs i ve n e c k l a c e

a l g o r i t h t u will y i e l d a fast a l g o r i t h t u t o g e n e r a t e n e c k l a c e s . For atiy o t he r forbidd'-u

s u b s t r i n g , n o efficient a l g o r i t h m wa s p r ev i o us K k n o w n .

T h e final r e s t r i c t e d c l as s o f n e c k l a c e s m e n t i o n e d are b r a c e l e t s . Hvncf lcls are n e c k ­

l a c e s w i t h e q t t i v a l e n c e u n d e r s tr i n g revers al . T h e y ari se in s e v e r a l areas i n c l u d i n g

c o l o r p r i n t i n g [27]. T h e p r o b l e m o f e ff i ci e n t l y g e n e r a t i n g b r a c e l e t s has been c o n s i d ­

e r e d b y s e v e r al r e s ea r c h e rs , btit h a s r e m a i n e d a n o p e n p r o b l e m for s o m e t ime . For

e x a m p l e . Li s onek [17] m o d i f i e d S a v a g e a n d W a n g ' s n e c k l a c e a l g o r i t h m [21] to g e n e r ­ a t e b r a c e l e t s T h i s a l g o r i t h t u has r u n n i n g t i m e 0 { n ■ w h e r e ) detiotes t h e n u m b e r o f A--ary b r a c e l e t s o f l e n g t h n. N o p r e v i o u s l y k n o w n a l g o r i t h m has a c h i e v e d a l owe r t i m e b o u n d . T h i s d i s s e r t a t i o n p r e s e n t s ftist g e n e r a t i o n a l g o r i t h m s for e a c h o f t he p r e c e d i n g o b j e c t s . C h a p t e r 2 p r o v i d e s a b a c k g r o u n d o n m a t h e m a t i c a l n o t a t i o n as well as a b a c k g r o u n d o n n e c k l a c e s . Ly t ido n w o r ds a n d p r e - n e c k l a c e s . A r e c u r s i v e a lg o r it hm for

(16)

g e n e r a t i n g t h e s e o b j e c t s is o u t l i n e d in detail.

In C h a p t e r i. an e f f ic i e nt a l g o r i t h m For g e n e r a t i n g bi nar y u n l a b e l e d n e c k l a c e s is

p r e s e n t e d , a l o ng w i t h a p r o o f s h o w i n g the a l g o r i t h m is C.AT.

In C h a p t e r 1. a i n o d i t i e d versi on of the r e c u r s i v e n e c k l a c e g e n e r a t i o n a l g o r i t h m is

o u t l i n e d . TIu'u. u s i n g t hi s m o d i h e d a l go r i t h m, a n tdhci ent a l g o r i t h m for g e n e r a t i n g

A-ary fi.xed d e n s i t y n e c k l a c e s is pr e s e nt e d, a l o n g w i t h a p r oo f s h o w i n g t h e a l g o r i t h m

is (CAT. .As an a [ ) p l i c at i on . t h e a l g o r i t h m is u s e d t o g e n e r a t e di f f e r e nc e c ov e r s .

In C h a p t e r 5. t w o a l g o r i t h m s are o u t l i n e d lor g e n e r a t i n g n e c k l a c e s w h e r e t h e

n u m b e r o f e ac h a l p h a b e t s y m b o l is lixed. The lirst a l g o r i t h m is s i m p l e , bu t d o e s not

a[>pear to run in c o n s t a n t a m o r ti x e i l ti me. I'he s e c o n d a l g o r i t h m is m o r e c o m p h w .

but e x p e r i m e n t a l e v i d e n c e i n d i c a t e s that it is C.A I , T h e t i m e b o u n d is p r o v e d in a

s p e c i a l case.

In C h a p t e r (i. s i m p l e c o u n t i n g t e c hni que s a r e u s e d t o der i ve t h e a l r e a d y k n o w n

f o r m u l a for e n u m e r a t i n g c ho r d d i ag r ams . In a d d i t i o n , t w o a l g o r i t h m s a r e d e vi ' l o p e d

for g e n e r a t i n g chor d d i a g r a m s . E x pe ri me nt a l r e s ul t s i n d i c a t e that th<’ l a t t e r o f t h e

t w o a l g o r i t h m s p r e s e n t e d r uns in c o ns t ant a m o r t i z e d t i m e .

C h a p t e r 7 c o m b i n e s a l g o r i t h m s for g e n e r a t i n g s t r i n g s and n e c k l a c e s w i t h a real ­

t i m e p a t t e r n m a t c h i n g a l g o r i t h m . The c o m b i n a t i o n o f t h e s e algorit h m s r e s u l t s in ( '.AT

a l g o r i t h m s for g e n e r a t i n g froth stritigs and c i r c u l a r s t r i n g s wi th f or bi d d e n s u b s t r i n g s ,

a n d n e c k l a c e s w i t h f o r b i d d e n L y n d o n subs t r i ngs . T h e a n a l y s i s proves t ha t t h e n u m b e r

o f s t r i n g s w i t h f o r b i d d e n s u b s t r i n g / is p r o p o rt i on a l t o t h e n u m b e r o f c i r c u l a r s t r i n g s

w i t h f o r b i d d e n s u b s t r i n g / .

In C h a p t e r S. a n e f f i ci ent a l g o r i t h m for g e n e r a t i n g Ar-ary b r a c e l e t s is p r e s e n t e d

a l o n g w i t h a p r oo f s h o w i n g t h e a l g o r it hm runs in c o n s t a n t a m o r t i z e d t i m e . T h e r e is

a l s o a br i e f d i s c t is s i o n o f s t r i n g s wi t h no O' s u b s t r i n g .

L y n d o n words o f l e n g t h ii c a n be used t o f or m a bas i s for t h e n - t h h o m o g e n e o u s

c o m p o n e n t o f t h e f ree Lie a l g e br a. C h a p t e r 9 o u t l i n e s a linear t i m e a l g o r i t h m for

g e n e r a t i n g a s p e c i a l b r a c k e t i n g o f t h e Lyn d o n w o r d s w h i c h c o r r e s p o nd s t o t h i s bas i s .

C h a p t e r 10 s u m m a r i z e s t h e research c o n t r i b u t i o n s m a d e in t h i s d i s s e r t a t i o n , a n d

(17)

Chapter 2

Background

['his c h a p t e r g i v e s a baekgroiitul o f tiec k l a ces. Lyiicloii w o r ds , a m i pr e - ne c k l a c e s a l o n g

with an o v e r v i e w o f a r ec u r s i v e n e c k l a c e g e n e r a t i o n a l g o r i t h n t . First, ther e is a d i s ­

cussion o f m a t h e m a l ical n o t a t i o n a n d an i m p o r t a n t l e m t n a .

2.1

P h i and mu

Two mi t nl i er t h e o r e t i c f u n c t i o n s a p p e a r frecpienlly t h r o u g h o u t t hi s d i s s e r t a t i o n . T h e

[■'ult r t ot i f lit f u n c t i o n on a posit i ve i n t e g e r n. d e n o t e d o( tt ). is t h e nitniber o f i n t e g e r s

in t he set ( 0 . 1... — 1 f t h a t ar e r e l a t i v e l y p r i m e to it. T h e Mo b i i i s f u n c t i o n / i ( / t )

o f a p o s i t i v e i n t e g e r n is d e l i n e d by t h e f ol l o wi n g formula:

/ i ( n ) =

( — I)'" if ft is t h e p r od u c t o f r d i s t i n c t p r i m e nutnbers.

0 o t h e r w i s e .

T h e f o l l o w i n g l e m m a , k n o w n as t h e .Mobiiis i nve r s i on p r i n c i p l e , cati b e u s e d t o

e t i ut nerat e m a n y o f t h e a p e r i o d i c o b j e c t s d i s c u s s e d in t hi s d i s s e r t a t i o n .

Le.MM.-v I I f f a n d g are f u n c t i o n s o n t he p o s i t i v e ni t ei j crs t h e n

</(«) = i f a n d o n l y i f f { n ) = Y ^ i . i { d ) g { ' ^ ) .

(18)

A p r o o f for t hi s l e m m a m a y b e founrl in [13].

2.2

B u r n sid e ’s lem m a

O n e o f t h e mo s t useful t o o l s for e i i u t ii e ra t ii i g e ot n h i n a t o r i a l o b j e c t s w i t h e c p i i v al e nc e

utider s o t n e g r o u p a c t i o n is B u r n s i d e ' s L e m t n a .

B i r n s i d E ' s Le.\1.\I.-\. [ f a grodj ) ( i act.s o n a s e t .s' <tnd Fi . r{ ( j ] = c .s'|f/(.s) = .s},

llirn t i n nt nnbt r o f cqui t ' ah n c f clas.^fs is g i r t n by

' J t O

-riiis l e m m a is u s ed t o e n u m e r a t e nil o f t h e o b j e c t s d i s c u s s e d in t hi s d i s s e r t â t iott

that h a v e ( xpt i val e nce u n d e r s o m e g r o u p a c t i o n . In [^articular, thi s l e m m a is u s e d

a l o n g w i t h s it npl e c o u n t i n g te c hni t pt e s t o d e r i v e ati e n u m e r a t i o n f o r mu l a for chor d

d i a g r a m s .

2.3

N eck la ces, L yndon w ords, and p re-n eck laces

T h e f u n d a m e n t a l o b j e c t b e h i n d each o f t h e a l g or i t h t ns d e s c r i b e d in t hi s d i s s e r t a t i o n

is t h e n e c k l a c e . . \ i nck'lacc is t he c a t i on i c a l r e p r e s e t i t a ti v e o f ati e i p t i v a l e n c e c l a s s o f

A-ary st ri t i gs uiuler r o t a t i o n . I nless o t h e r w i s e s t a t e d , t h e c a n o n i c a l r e p r e s e n t a t i v e is

t h e l e x i c o g r a p h i c a l l y s m a l l e s t e l e m e n t in t h e ecpi i va l e nc e c lass. .As an e x a m p l e , t h e

set o f all b i n a ry t ie ckl ac es o f l e ng t h 1 is { 0 0 0 0 . 0 0 0 1 . 0 0 1 1 . 0 1 0 1 . 0 1 1 1 . 1 1 1 1 }. T h e se t o f

all A'-ary n e c k l a c e s w i t h l e n g t h n is d e n o t e d by N t ( n ) . T h e c a r d i n a l i t y o f t h i s se t is

d e n o t e d b y . \ \ . ( n ) .

1 si tig t h e l e x i c o g r a p h i c a l l y s m a l l e s t e l e m e n t as t h e c a n o n i c a l r e p r e s e n t a t i v e , an

a p e r i o d i c n e c k l a c e is c a l l e d a L y n d o n u'ord. T h e set o f all At-ary L y n d o n w o r d s w i t h

l e n g t h n is d e n o t e d b y Lfc(n) a n d h a s c a r d i n a l i t y L k ( n ) . T h e t e r m p e r i o d i c ne c kl ac e

(19)

A wor d is c a l l e d a j>r(- ne c k l a c t i f it is t h e pr el i x o f s o m e necklace. I'he set o f all A:-ary p r e - n e c k l a c e s w i t h l e n g t h n is d e n o t e d by P t ( n ) a n d has c a r di na l i t y T H E O R E M 1 The folloii'inij f o n n u l a e a r t v a l i d f o r al l n > [. Ic > [: A’r-(f') = - o( d) k' "' ‘. I 2 . 1 ) " 7 | n

/,(..( n) = -

fi{(l)k

.

l-.d)

l \ n Pki ' i ] = ' ^ L k ( i ) . i2.d) f = l

P i t o O E : The ecj uat i ons for l.k-(n) a n d \ ar e ver i l i ed by ( li l be rt and Hi ordai i [12].

1 he etpial ion for l \ \ n ] f ol l ows f rom L e m m a (i ( s t a t e d l a t er in t his s e c t i o n ) .

W e n o w s t a t e several l e m m a s a b o u t n e c k l a c e s . L y n d o n wor ds, and p r e - n e c k l a c e s .

I'he f o l l o w i n g t w o l e m m a s are provi'd in [ 2 l | .

LE.M.MA 2 [ f o ts a i i n- kl ar t . t h i n o ’ is a n t c k l a c i f a r t > 1. LkmM.A 3 I f o h t P k i ' i ) i-'‘ p n - n t r k l n c t . i rhd' f h < k - 1. l i n no( / ) - f 1) c Li ,( / j ) . T h e n e x t l e m m a can b e pr o v e d d i r e c t l y f r om I he d e l i n i t i o n s of a n e c k l a c e an d a p r e - n e c k l a c e . lne<|iialities b e t w e e n w o r ds a r e a l w a \ s w i t h respect to l e x i c o g r a p h i c o r der. Le.\I.\I.-\ 4 Lc l n = (/| • • ■ <i„ hf a pv t - n t c k l a c t . I f x is a s a h s t r i n g o f a wi t h It i nj t h k. t i n II X > « [ • • • Ilk-R e n t e n a u e r [19| g i v e s a usef ul l e m m a a b o u t L y n d o n words . LE.MM.A 5 f f n a n d I a i r L y n d o n w o r d s

wi t h

a < d . t he n a J is a L y n d o n wo r d . T h e f o l l o w i n g l e m m a f r o m R u s k e y [20] c h a r a c t e r i z e s pre- ne ckl aces. It u s e s t h e f u n c t i o n l y n o n s t ri ng s w h i c h is t h e l e n g t h o f t h e l o n g e s t L y n d o n prefix o f t h e s t r i n g . F o r m a l l y , i f a i a > • • • ‘in is a k - a r y s t r i n g t h e n

l y n ( a i a

-2

• • • a„) =

m a x { l < p <

« [ « 1 0 2

• ■ • Op € Lfc(p)}.

(20)

p r o c e d u r e Necklace ( /. /) ;

i n t e g e r

):

l o c a l j : integer: b e g i n

i f

t > n

t h e n

Printlt( p )

e l s e b e g i n

a, : = (it-p\

Necklace! / + I. /) ):

f o r j t {«(_p -r I k - 2. k - [ } d o b e g i n

a, : = j :

Necklace! / + 1. / ):

en d : e n d : end:

Fi g u r e J. I : [ h e r e c u r s i v e necklace' a l g o r i t h m L e m m a 6 L t t k - a r y . i l ni uj a = n , - Un «'/r/ p = l y n ( a ) . The n a t Pt -( n) i f an el o nl y i f a . - p = a . f o r j = p + . n. T h e f o l lo wi n g , v e r y i m p o rt a n t t h e o r e m , is prove d in [2t)j. It l e ad s t o t h e recursive' l U'cklacf'geiu'ration a l g o r i t h m d e s c r i b e d in t h e ne x t s n b s e c t i o n . It c a n a l s o b e u s e d

to de'velop a l i n e ar time' a l g o r i t hm l e q n i v a l e n t t o D u v a l ' s a l g o r i t h m [!)]) for f a c t or in g

a string i nt o L y n d o n words. T h i s a l g o r i t h m , in t ur n, y i e l d s a l i near t i m e a l g o r i t h m

for finding t h e n e c k l a c e o f an a r b i t r a r y s t r i n g [20].

Tilf.OHI'.M 2 Le t (> = i i p i , - - - ( i n - i *= P e l " - 1) eind p = l y n i a ) . Ti n .-<triny o/i Ç P; . f ; ) ) i f a n d o n l y i f On-p < b < k — l . Fur l l n n n o r i .

l y n { a b ) = <

p i f h = a n - p

n i f ein-p < b < k —

2.3.1

A recursive necklace generation algorithm

T h e recursive n e c k l a c e g e n e r a t i o n a l g o r i t h m

NecklacefL

p). s h o w n in F i g u r e 2. 1. fol­ lows d i rect l y f r o m T h e o r e m 2. T h e g e n e r a l a p p r o a c h o f t hi s a l g o r i t h m is t o g e n e r a t e

all length n p r e - n e c k l a c e s . T h e p r e - n e c k l a c e b e i n g g e n e r a t e d is s t o r e d in t h e array

a: o n e p o s i t i o n for e a c h c ha r ac te r . W e a s s u m e t h a t üq = 0. T h e i n i t ia l call is

Neck-

(21)

9

[)ro-ii('fklace. At t h e b e g i n n i n g o f e a c h r e cu r si v e call t o N e c k l a c e f / , / i ) . t h e l e n g t h o f

t h e [ )r e - ne c k l ac e b e i n g g e n e r a t e d is / — 1 a n d t h e l e n g t h o f t h e l o n g e s t L y n d o n prefix

is [). A s l on g as t h e l e n g t h o f t h e c u r r e nt p r e - n e c k l a c e is less t h a n n. e a c h call to

N e c k l a c e ! t . p) m a k e s o n e r e c u r s i v e call for e a c h v a l u e front t o k — I, u p d a t i n g t h e

v a l u e s o f l)oth t a nd p in t h e pr o c e s s . T h i s a l g o r i t h m c a n g e n e r a t e n e c k l a c e s . L y n d o n

w o r d s or p r e - n e c k l a c e s o f l e n g t h i> in l e x i c o g r a p h i c or de r by s p e c i f y i n g w h i c h o b j e c t

w e want t o g e n e r a t e . I h e f u n c t i o n Printlt(//) a l l o w us t o d i f f e r e n t i a t e b e t w e e n the.se

v ar io u s o b j e c t s as s h o w n in Lalth' J . l .

S e q u e n c e t y p e P r i n t l t ( p )

P r e - n e c k l a c e s ( P t ( t i ) ) pri nt l n( ui • • • u,, )

L y n d o n wor ds ( L< . ( n ) ) i f p = n t h e n p r in t ln | e , ■■■11,, )

N e c k l a c e s i f 11 m o d p = 0 t h e n pri ntl ni <t, •• •</„ ) 1 a b l e 2.1; l)iffer«uit o b j e c t s o u t p u t by dilTetcnt v er s i o n s o f Printit

T Ik' cofTiputation t re e for N e c k l a c e ! / . / ; ) c o n s i s t s o f all p r e - n e c k l a c e s o f l e ng t h less

t h a n or e q u a l t o n. .As a n e x a m p l e , w e s h o w a c o m p u t a t i o n t r e e for .Vj! I) in Fi g u r e

2 . 2 . B y c o m p a r i n g t h e n u m b e r o f n o d e s in t h e c o m p u t a t i o n t r e e t o t h e n u m b e r o f

(22)

[()

/

0000 0001 0010 0011 0 1 0 1 0 1 1 0 OUI l i l t

(23)

C hapter 3

U nlabeled N ecklaces

T h i s r l i a p t c r outline's a C A T a l g o r i t h m for ge'iu'rating b i n a r y unlahe'lt'cl tu'cklarcs.

3.1

B ackground

A n u n l nb r l f d nt ckUi rr is I he' r a no ni e al re'pre'se'iitative'( l e ' x i r og r ap h i e al l y s ma l l e st eh'-

m e n t ) o f an t'epiivalence c l a s s o f s t r i n g s u n d e r r o t a t i o n a n d p e r i t m t a t i o n o f its a l p h a b e t

s y m b o l s . From this d e f i n i t i o n , t h e n e c kl a c e s 0001 a n d 0111 a r e in the? s a m e eepiiv-

alerice- c la ss si nc e o n e c a n b e transforme'd inte> t h e o t h e r b y p e r m u t i n g t h e s y m b o l s

0 a n d I. T h e set o f all A-ary unlabeh'el ne'cklace's w i t h h' n g t h d is denot t ' d N ; ( ; H

w i t h care l i nal i l y .V;.(n ). Fe)r e . xa mp l e . N>( I) = { 0 0 0 0 . 0 0 0 1 . 0 0 1 1 . O I O I }. An iinldht h d

L i j n d o n w o r d is an a p e r i o d i c i m l a b e l e d n e c k l a c e . The? set o f all A:-ary h'ngth ii u n ­

l a b e l e d L y n d o n words is d e n o t e d Lfc(n) w i t h c a r d i n a l i t y L; . ( n) . w o r d is calleel an

t i nl a b f l r d p i r - r u c U a r r if it t h e pr efi x o f s o m e u n l a b e l e d n e c k l a c e . T h e set o f all T-ary

u n l a b e h ' d pre-necklace's is d e n o t e d by P t ( n ). a n d has c a r d i n a l i t y l \ { n ) .

T h e f ol l owi ng t h e o r e m g i v e s e n u m e r a t i o n fortnul as for t h e s e o b j e c t s in t In' In nary

c a s e . G e n e r a l formulas for . \ T ( n ) a n d L k [ n ) a l s o e x i s t a n d c a n b e f o u n d in [12].

T h e o r e m 3 The f o l l o w i n g f o r m u l a e are v a l i d f o r all n > 1. A: > 1;

- V i ( n ) = V ( 3 . 1 )

I n

(24)

IJ — ~ ^ jL(dyi'^^'^. i-5.2) l u ^ 0(1(1 i \ n P i i ' i ) = ^ Z j ( / ) . ( j . j ) <=t

P r o o [ ' : [ h e i*quatioii.s for Aj ( / / ) ami L ^ i " ) art' from Cillx'rl am i Hiordan [12]. I tio equation for P<(n] follows from L em m a S ( s ta t e d in the ne\-t sert ion). G

3.2

G en era tin g binary u n la b eled n ecklaces

Thi s s e c t i o n foru.ses on generalinu; Linary unlabe'led n e c k l a c e s . It is an o p e n p r o i i h ' m

to g e n e r a t e i m l a b e l e d n e c k l a c e s over a g e ne r a l a l p h a b e t o f s i z e k.

[binary i m l a b e l e d n e c k l a c e s c a n be g e n e r a t e d by g e n e r a t i n g all binary n e c k l a c e s

and I hen p e r f o r m i n g a test on e ac h m ' ck l a c e t o d e t e r t n i n e w h e t h e r or not it is tiu'

u i d a b e l e d r ep r e s e n t a t i v e . In t h e bi nar y c a s e , a n e c k l a c e a n d i t s c o m p l e m e n t a r e in

the s a m e e c pn v al e nc e c l ass. I he re fore, t h i s test can b e p e r f o r m e d by t a k i t i g t h e

c o m p l e m e n t o f t h e ge ne r at e , I n e c k l a c e an d u s i n g a n e c kl a c e l i n d i n g a l g o r i t h m t o l i nd

its c o r r e s p o n d i n g nec kl ac e. S u c h an a l g o r i t h m r uns in l i n e a r t i m e (see C h a p t e r 2 . 2 ) .

T h e r e s u l t i n g ne c kl a c e is t h e n c o m p a r e d t o t h e original: i f t h e original is not l ar ger,

then it is a n i ml ab e le d n e c k l a c e . T h i s a l g o r i t h m y i e l d s a n o v eral l rnt mi ng t i m e o f

0(11 ■ i V ( / / ) ) . wh i ch is far f rom elf i ci e nt .

d o i m p r o v e upon thi s n a ï v e a l g o r i t h m , t h e l i near t i m e t es t required at t h e eni l

o f t h e n e c k l a c e g e ne r a ti o n m u s t b e e l i m i n a t e d . T h e r e m a i n d e r o f this s e c t i o n is

used t o p r o v e T h e o r e m o. T h i s t h e o r e m for u n l a b e l e d p r e - n e c k l a c e s is a n a l o g o u s t o

T h e o r e m 2 for pr e - ne c k l ac e s . It s u g g e s t s t h e a d d i t i o n o f a n o t h e r p a r a m e t e r c t o t h e

r ou t i n e

Necklace!

t . p ) w hi c h re pl a c e s t h e n e e d for t h e linear t i m e t e s t . Se v e r a l l e m m a s are nee<led b e fo r e we s t a t e a n d prove t hi s t h e o r e m . T h e f o l l o w i n g t wo l e m m a s a r e

a n a l o g o u s t o L e m m a 2 a n d L e m m a 6 for n e c k l a c e s .

Le.M.M.A 7 I f a = « 1 • • • G

N.

t he n a ' G

N

f o r t > I.

(25)

13

by clofinition o f a n u n l a h e l e c l neckl aco. J m u s t be gr e a t er t h a n or e q u a l t o a a n d t h u s

y' m us t be g r e at e r t h a n or equal to o ' . F r o m L e m m a 2 o ' is a n e c k l a c e a n d t h e r e f o r e

by definition n ' is a n u n l a b e l e d n e c k l a c e for f > l .

LKMMA S /,f7 n = bt a st rl i i fj m i d I d p upKi l ffit Ut uj t h nj the l oi uj cs t ai i l dbf l t d Lijiidott p n j i x o f a . Tin n o c P ij f ind oidfi ij = i i , J o r j — p + 1 i t .

PltOOF: If (ij_p = Uj for j = /) f 1 u . t h e n o = i ‘S for s o m e t > L w h e r e

I = ui ■ • ■ Up t

L

a n d A is a pn'iix o f i . B y L e m m a 7. is an u n l a b e t e d n e c k l a c e a n d thus o Ç P . ( ' o m c r s e l y . a s s u m e that o 6 P- II i = </ an d p ^ </ t h e n

t h e r e must exist a Ly t i d o n prefix o f n w i t h letigth greateu' t h a n p that is not in

L.

T h i s i mp l i e s t h a t t he r e e x i st s a p e r t n i i t a t i o n rr o f t h e a l p h a b e t s y m b o l s s uc h t h a t - ( ( i \ . . . t i . i ) < <i[ . . . a . , . Thi s c o n t r a d i c t s t h e as s t i tnpt i on t h a t a is an u n l a b e l e d

p r e- ne ckl ace , s i n c e n o m a t t e r what w e a p p e n d t o t he s t r i n g o . it c a n n e v e r b e an

i t nl abel ed tiecklace. \ o w si nc e we m u s t h a v e p = h p p n ). Iiy L e m m a IL = Oj for

J = /) + 1 n .

For binary s t r i n g o = u i u . ’ • • ■ let R o t ^ f o ) d e t i ot e t h e set o f all c o m p l e m e n t e d

r o t a t i on s u, • • • t i ndi ■ ■ ■ <i,-i o f o . w h e r e 1 < / < k. 1 he set N , ( n ) c o n s i s t s e x a c t l y o f

t h o s e necklaces o t h a t s a t i s fy r > o for all r € R o t , , ( t v ) . O b s e r v e t ha t

i f |.cj = ji/|. t he n ,r < ij if a m i otily if T > ÿ. (3. 1)

T H E O R E M 4 Le t o = t M i ( n ) - I f t here is a k s uc h t hat , f o r e v e r y r t R o t t ( n ), r > Q m i d u^+t • ‘ ' "n = ui ■ • - n n - c . t he n o 6 N ) ( « ) .

P r o o f : By t h e d e h n i t i o n o f an u n l a b e l e d n e c k l a c e , a n e c k l a c e is its u t i l a b e l e d r e p r e­

s e n t a t i v e if an d o n l y i f it is less t han or e q u a l t o each o f its c o m p l e m e n t e d r o t a t i o n s .

T h u s , it miist b e s h o w n that r > n for all r «= R o t ^ f n ) . It is g i v e n t h a t all r t

R o t j t ( a ) s at i s f y t h i s c o n d i t i o n so it m u s t o n l y h e s h o w n t ha t cij^i • • ■ (inUi • • ■ Oj > a

for k < j < n.

S i n c e flfc+i ■ ■ ■ ein = «t t a k i n g x = Oj +i • • • a„ in L e m m a 4 y i e l d s e i t h e r

(26)

11

is t r i v i al . In I tic l a t t e r c a s e c o n s i d e r a nd l o o k at t w o s u h c a s e s . If + 1 < k. t h e n r = • • ■ a ^ a i ■ ■ ■ n„ _, t R o t i ( a ) . r i i n s r > a w h i c h i m p l i e s + t • «n > ■ ■ ‘ «j- If n — J + I > k . t h e n a „ - j + i ■ ■ • n,, is a s u b s t r i n g o f ai;+i ■ ■ ■ (In a n d is t h e r e f o r e a s u b s t r i n g o f t h e p r e - n e c k l a c e u, •• B y L e m m a 1. > (li ■ ■■ < 1 , . riuis in b o t h s u b c a s e s ■ ■ Hn > u, • • • Hj. , \ o w

t i n- j +i ■ ■ ■ (In d “ i - ' “j- • iHis in l)otli su b c a ses (i„-, +i ■ ■ • 'ht d n, • • • <ij. , \ o w using I d. II. we h a \ e ui ■ • • a. > (t„-, + \ ■■■(!„ which im p lies that 0, ^1 ' ' ' " '/'i ■ ■ ■ Uj > n for

k < J < I).

C t t RO[ .( .. vm I Z . c / a = «1 • • ■ (I,, £ N j ( n ) . [ f a , ■ ■ ■ <in > <i\ ■ ■ ■ < U - , + i f o r al l 1 < / < a

Iht i ) o /.s ail ui i l a b i t f d nt c kl ac t .

P m i O P : If (/, •• • ((„ > f/i • ■ • . t h e n a, ■ ■ ■ a„u\ • ■ • i / . _i > o . If t h e r e e x i s t s a s m a l l e s t ; s uc h t h a t a, ■ • • a„ ~ u, + i t h e n , by I ' h e o r e m 1. n is an u n l a b e l e d

necklace'. O t h e r w i s e , o is an u n l a l i e l e d n e c k l a c e by d e h t i i t i o n .

D e l i n e c mn ( U | • • ■ u,,) to b,' I he s m a l l e s t p o s i t i v e val ue r for w h i c h

</ • ( I n = " 1 • • • . ( : { . " ) )

or a if no such v a l u e o f c e x i s t s . For e x a m p l e , c m/ ; ( ODD 1 11000 111) = re///( ( 0 1 1”' ) =

1. a n d rof//(0'‘ ) = n: t h e s e last t wo e x a m p l e s represent e x t r e m e v a l u e s for c o m . O n e

tinal l e m m a is g i v e n b ef ore st at i i ui t h e m a i n t he or e t n. LE'..\IM.\ 9 .1 b i n a r y s t r i n y n = u, ■■•//„ i> an i t n l a b t h d p r f - nr c k l a c t ij a n d o n l y i f a is a p r t - n t c k l a c r a n d a, ■ ■ • «r. > U| • f o r all 1 < / < n. P r o o f : . As s ume t h a t o is an u n l a b e l e d p r e - n e ck l a c e . S i n c e P ( n ) is a s u b s e t o f P i n ) t h e n a is a p r e - n e c k l a c e . B y d e h n i t i o n o f a n u n l a b e l e d p r e - n e c k l a c e t h e r e e x i s t s an u n l a b e l e d t i ec k l a c e s u c h t hat s = a S for s o m e s t r i n g S. T h u s by t h e d e f i n i t i o n o f a n u n l a b e l e d n e c k l a c e a, ■ ■ ■ <1,^ > ui • • - u „ _ , +t for all 1 < / < T o p r o v e t h e c o n v e r s e , let p = l y n ( a ) . If n m o d p = 0 t h e n a is a n e c k ­ l a c e . B y C o r o l l a r y 1. a is also a n t i n l a b e l e d n e c kl a c e a n d t h u s b y d e f i n i t i o n q is a n u n l a b e l e d p r e - n e c k l a c e . O t h e r w i s e i f n m o d p ^ 0 t h e n w e c o n s t r u c t a s t r i n g

(27)

l ô

J = ((f, ' - o f le n g t h m b y e x t e n d i n g n . B y o b s e r v i n g t h a t « i •••<;,, is an

u n l a b e t e d n e c k la c e (using t h e f a c t t h a t - a,, is a n e c k l a c e a n d C o r o lla r y 1 ) w e g e t

«I ■■■cip < (1, • • • (/prti • • • li,_ i for all 1 < f < /). T h u s b y ( 3 .4 ) w e h a v e n [ • • • dp >

a, (ipdi • • • « , _ ( . T h e r e fo r e for I < / < p [ n / p \ w e h a \ e a, - ■ ■ > «[ + i.

A g a in s i n c e n, • • • « ,, is an n n l a b e l e d nec k la c e . U; • • • > nt • T h u s w e ha\'e

( / , • • • (/,„ > n, ■ ■ _i for p [ i i / p\ < I < III. S o w s i n c e i is a n e c k l a c e C o r o l la r y

I s h o w s th a t i is an n n h d x d e d n e c k la c e , and t h u s bv définit ion o is an n n l a b e l e d

p r e - n e c k l a c e .

TtlF.ORt'.M 5 [ . (t o = (/[(/J • • ■ c P i ( " - I) iintl r = r n i n [ o ] . T h f st ri i uj o6

P j( ;; ) i f (III(I oiilii ij III o h ^ P j ( n | a mi I ii I n,, - U o r h = - h i r t l u r i i i o n

II) III( o 6 )

•J h

-P ltO O F : .A ssu m e that o h «2 P j ( n ) . By L e m m a 9 w e also h a v e o h f P j ( n ) . If

n . = /) = 1 th e n the s tr in g n\ ■ ■ - ( i n-- > a c o n t r a d i c t i o n t o t h e ile f in i t io n

o f an n n l a b e l e d pre-neck la c e . T h e r e f o r e eil her = 0 or h = 0. If r;,,_ = I a n d

6 = 0 t h e n 6 = n „ _ .. I'hus e i t h e r n„_,. = Ü or 6 =

l o p r o v e t h e co n v tn se w e n e e d o n ly sh o w t h a t > a , , for all

1 < i < II by L e m m a 9. B e c a u s e o *2 P j ( n - 1) a n d r = c o n r ( o ) w e o b s e r v e t h a t

(I. • ■ • (i„_i > (ii •••((„_, for a ll 1 < / < c. T h u s w e c le a r ly a ls o h a v e ii, ■ ■ ■ (in >

</i - - for I < ' < c. If i~in-c - 6 th e n ■ ■ ■ d„ = rt[ ■■■iin-j by d e f i n i t i o n

o f c c i iii( o ) . If = 6 = 0 t h e n w e have by a s i m i l a r a r g u m e n t t h a t [ • • • >

( i i - - - r i n - c - S o w a p p ly in g L e m m a 4 for e i t h e r c a s e w e get u, ■ ■ ■ r/„ > U| - - -

for c + I < I < n. T h e r e f o r e n, • • • > n, •• •( („ _ ,+ ! for all 1 < / < tt an d t h u s

o6 t P > ( u ) .

F u r t h e r m o r e if e„_.. = 6. t h e n clearly cui i i ( ol j ) = c. If 6 = = 0. t h e n

cui i i ( Qb) = n s in c e there is n o v a l u e o f c for w h ic h (3.Ô ) h o ld s. N o t e t h a t t h e c a s e

a„_.- = 6 = 1 c a n n o t o c c u r b y t h e d is c u s s io n in t h e first p a r a g r a p h o f t h e pro of.

(28)

IG

P r o c e d u r e Unlabeled ( t . j j . c : i n t e g e r ); b e g i n IÎ t > n

t h e n

Printlt( p );

e l s e b e g i n

i f

= 0 t h e n b e g i n

i f

= 0 t h e n b e g i n

a, ; = 0; Unlabeled( t [. p. t ):

e n d ;

( I , : = I : i f = 1 t h e n Unlabeled( / + 1. /). c ): e l s e UnlabeledI t I . t. c ): e n d e l s e b e g i n a , : = 0: Unlabeled( t + I. p . <■ ):

end: end; e n d ;

F ig u r i'M .l; r u l a b c l c d Id n a r v n c c k la c t 'a lm ir ii liin ra n h r g en rra tecl by i n t r o d u c i n g i b c a d d i t i o n a l p a r a m e t e r c t o t h e p r e -n e c k l a c e g e n ­ e r a t i o n a lg o r it h m N e c k l a c e ! F /t). P s e u d o c o d e for this a l g o r i t h m is g iv e n in F ig u r e ;}.l.

T h e i n i t ia l call is U n la b e le d !2. 1. 1). first in it ia liz in g r /o = a, = IT I ’ld a b e le d n e c k la c e s .

L v n d o n w o rd s, and [)r e -u e c k la c es can all lie p r o d u c e d by u s i n g Fable d.l as liefore.

3.3

A nalysis

O b s e r v e t h a t th e c o m p u t a t i o n tr e e o f U n l a b e le d ( T p . c) is a s u b t r e e o f th e c o m p u t a t i o n

tr e e o f N e c k la c e ! T /i) a n d t h a t o n l y c o n s t a n t c o m p u t a t i o n is p e r f o r m e d at e a c h n o d e

o f t h e t r e e . F u r th e r m o r e , t h e n u m b e r o f n n l a b e l e d b in ar y n e c k l a c e s is at least h a l f t h e

n u m b e r o f lab e led b in a r y n e c k la c e s . T h e s e o b s e r v a t io n s [irove t h e follo w in g t h e o r e m .

T h e o r e m G Al g o r i t h m Un l ab e le d[ t. p . c ) f o r g e n e r a t i n g b i n a r y unl abel ed nt c kdac es is

C A T .

It r e m a i n s an i n t e r e s t i n g c h a l l e n g e t o e x t e n d th e s e i d e a s t o g e n e r a t e n n l a b e l e d

n e c k l a c e s o v e r n o n -b in a r y a l p h a b e t s ; t h e r e s e e m s t o b e n o o b v i o u s way to e x t e n d

(29)

Chapter 4

Fixed D en sity N ecklaces

T h i s c h a p r r r d c v r l o p s a C A T a lg o r i t h in for "onorarinu, tixi’d lU'usitv iK 'cklares. An

a t l d i t i o n a l algo rilliiii is p r o s o n tc d for t h o liin a r y c a se . A s an a p p l i c a t i o n , a n a h io r it h in

is oiitliiK'd lo u;cnciatc (lit fc r c n c c c o \ c r s .

4.1

B ackground

[’h e (ff n.s/Z/y o f a s t r i n g is (iefineti t o h e t h e n n n ih e r o f n o n -z e r o c h a r a c t e r s in th e

s t r i n g . T h u s , a le n g th n s t r i n g w ith d e n s i t y «/ c o n t a i n s e x a c t l y n — ,/ z e r o s , ['he set

o f A'-ary n ec k la c e s w i t h d e n s i t y </ a n d l e n g t h n is r e p r e s e n te d hy a n d has

c a r d i n a l i t y For e x a m p l e N d I - ‘2) = { 0 0 1 1 . ÜÜ12.0 0 2 1 . 0 0 ‘2'2.0 1 0 1 . Ü 1 0 2 . 0 2 0 2 } .

S i m i l a r l y , th e set o f fix e d d e n s i t y L y n d o n w o r d s is r e p r e s e n t e d by L t ( n . d ) w i t h c a r d i­

n a l i t y L k i n . d ) . T h e s e t o f fixed d e n s i t y p r e - n e c k la c e s is d e n o t e d by P i , ( n . d ) a n d has c a r d i n a l i t y In a d d i t i o n to t h e s e f a m ili a r t e r m s w e in t r o d u c e t h e set P [ . ( n . d ) w h i c h is th e e l e m e n t s o f P ; . ( ;;.</) w h o s e last c h a r a c t e r is n o n -z e r o . Its c a r d i n a l i t y is d e n o t e d / ’( ( n . d ) . F i x e d d e n s it y n e c k l a c e s c a n be c o u n t e d u s in g t h e o b j e c t d i s c u s s e d in t h e fol­ l o w i n g ch a p ter ; n e c k l a c e s w h e r e t h e n u m b e r o f e a c h a l p h a b e t s y m b o l is f ix e d . Let N ( t t o . I l l / t t _ i ) d e n o t e t h e se t o f n e c k l a c e s c o m p o s e d o f ii, o c c u r r e n c e s o f t h e s y m ­

b o l i . for / = 0. 1___ _ At— I. T h e c a r d i n a l i t y o f th is se t is d e n o t e d A’fnu. i ? i t U i )

(30)

IS

d e n o t e d b y L ( / ? o . n [ r u - i ) . w i t h c a r d in a lit y L { » o ~ n i ). T h e t w o e n u m e r ­

a t io n Form ulas s t a t e d in t h e f o l l o w i n g th e o r e m a re k n o w n from ( l i l h e r t a n d R i o n l a n

•d

T l I E O l t E M I The f o l l o w i n g f o r mi i l i i f are rnl i d f o r nil n, > 1. A- > 1;

j I j l - ' / I n r , . n , /ifc _ i ) 1 ( n / _/ I ! / . I " u - " t i i h - \ ) = - > f ‘ U ) - - - — 1- - - :- - - — 7 I I d I ^ ( " o / j l l - ' - l U i - i / j ) ! j|:;d-i(no./ii /Ik_ I ) Let t h e d e n s i t y o f t h e n e c k la c e d = u , H hUfc-i a n d Uq = n - d . To g e t t h e n u m b e r o f fix('d ( h 'u s it y n e c k la c e s ( a n d L y n d o n w ords) w it h le n g t h n an d d e n s i t y d. w e su m

o v e r all p o s s i b l e v alu e s o f » i - " j ."t—i to o b t a in :

. \ i ^( n. d) = ^ 2 . \ { n — d . i i i ... ( I.S) 111 1 h f i t - i = t l L k ( i i . d ) - ^ L { n - d . n i ...i i k - \ ) (-1.1) / I ( — I — In th e b i n a r y c a s e th e s e e x p r e s s i o n s s im p lif y as fo llo w s . V i o . . a = i E o U ) (

-C u r r e n t ly , it is not k n o w n h o w t o c o u n t h xed d e n s i t y [) re-neck laces.

4.2

G en era tin g fix e d d en sity necklaces

W e u s e a t w o s t e p a p p r o a c h t o d e v e l o p a fast a l g o r i t h m for g e n e r a t i n g f ix e d d e n s i t y

n e c k l a c e s . F ir st w e c r e a t e a n e w n e c k l a c e a l g o r i t h m b a s e d on t h e r e c u r s i v e n e c k l a c e

Referenties

GERELATEERDE DOCUMENTEN

Kortom, er wordt verwacht dat het belang om een aantrekkelijke en competitieve vestigingsplaats voor internationaal kapitaal te zijn in stedelijk beleid zal toenemen door (1)

Additionally, the research of Kannan (2017) showed also there is a missing field in the literature about the influence of personal devices on the relationship between brand

As the CSPFTZ is mainly focused on opening up service sectors like the financial services and the transportation sector, the reform of the administrative system, and the

2a) High power alters will positively influence the chances between centrality and winning the Nobel prize. 2b) High power alters will positively affect the relationship

The planning system (and its instruments) is therefore placed on this middle level. The politico-juridical rules determine how resources, the lowest scale, may be

It predicts that tap asynchronies do not differ between the left and right hands if they were exposed to different delays, because the effects of lag adaptation for the left and

IDS: Immediate Dentin Sealing; DDS: Delayed Dentin Sealing; IDS-1L: one adhesive layer; IDS-2L: two adhesive layers; IDS-F: one adhesive layer and one flowable layer; DDS: no

' nto account. These include reduced consplC lrt y of vulnerable road users, Increased fue l usage, environmenta l con c erns, more frequently burned-out bulbs, and