University of Bristol - Explore Bristol Research. Peer reviewed version. Link to published version (if available): /j.jda

Size: px
Start display at page:

Download "University of Bristol - Explore Bristol Research. Peer reviewed version. Link to published version (if available): /j.jda"

Transcription

1 Strikovsky, T. A., & Vildhøj, H. W. (2015). A suffix tree or not suffix tree? Journl of Discrete Algorithms, 32, DOI: /j.jd Peer reviewed version Link to pulished version (if ville): /j.jd Link to puliction record in Explore Bristol Reserch PDF-document University of Bristol - Explore Bristol Reserch Generl rights This document is mde ville in ccordnce with pulisher policies. Plese cite only the pulished version using the reference ove. Full terms of use re ville:

2 A Suffix Tree Or Not A Suffix Tree? Ttin Strikovsky 1 Higher School of Economics (Russi), tt.strikovsky@gmil.com Hjlte Wedel Vildhøj Technicl University of Denmrk, DTU Compute, hwv@hwv.dk Astrct In this pper we study the structure of suffix trees. Given n unleled tree τ on n nodes nd suffix links of its internl nodes, we sk the question Is τ suffix tree?, i.e., is there string S whose suffix tree hs the sme topologicl structure s τ? We plce no restrictions on S, in prticulr we do not require tht S ends with unique symol. This corresponds to considering the more generl definition of implicit or extended suffix trees. Such generl suffix trees hve mny pplictions nd re for exmple needed to llow efficient updtes when suffix trees re uilt online. Deciding if τ is suffix tree is not n esy tsk, ecuse, with no restrictions on the finl symol, we cnnot guess the length of string tht relizes τ from the numer of leves. And without n upper ound on the length of such string, it is not even cler how to solve the prolem y n exhustive serch. In this pper, we prove tht τ is suffix tree if nd only if it is relized y string S of length n 1, nd we give liner-time lgorithm for inferring S when the first letter on ech edge is known. This generlizes the work of I et l. [Discrete Appl. Mth. 163, 2014]. Keywords: Reverse engineering; suffix trees; suffix links; suffix tour grphs. 1. Introduction The suffix tree ws introduced y Peter Weiner in 1973 [19] nd remins one of the most populr nd widely used text indexing dt structures (see [1] nd references therein). In sttic pplictions it is commonly ssumed tht suffix trees re uilt only for strings with unique end symol (often denoted ), thus ensuring the useful one-to-one correspondnce etween leves nd suffixes. In this pper we view such suffix trees s specil cse nd refer to them s -suffix trees. Our focus is on suffix trees of ritrry strings, which we simply cll suffix A preliminry version of this work hs een presented t the 25th Interntionl Workshop on Comintoril Algorithms in Octoer Corresponding uthor. Prtly supported y Dynsty foundtion. Preprint sumitted to Elsevier Jnury 12, 2015

3 () () (c) Figure 1: Three potentil suffix trees. Internl nodes re lck, nd leves re white. () is -suffix tree, e.g. for. () is not -suffix tree, ut it is suffix tree, e.g. for. (c) is not suffix tree. trees to emphsize tht they re more generl thn -suffix trees 2. Contrry to -suffix trees, the suffixes in suffix tree cn end in internl non-rnching loctions of the tree, clled implicit suffix nodes. Suffix trees for ritrry strings re not only nice generliztion, ut re required in mny pplictions. For exmple in online lgorithms tht construct the suffix tree of left-to-right streming text (e.g., Ukkonen s lgorithm [18]), it is necessry to mintin the implicit suffix nodes to llow efficient updtes. Despite their essentil role, the structure of suffix trees is still not well understood. For instnce, it ws only recently proved tht ech internl edge in suffix tree cn contin t most one implicit suffix node [4]. In this pper we prove some new properties of suffix trees nd show how to decide whether suffix trees cn hve prticulr structure. Structurl properties of suffix trees re not only of theoreticl interest, ut re essentil for nlyzing the complexity nd correctness of lgorithms using suffix trees. Given n unleled ordered rooted tree τ nd suffix links of its internl nodes, the suffix tree decision prolem is to decide if there exists string S such tht the suffix tree of S is isomorphic to τ. If such string exists, we sy tht τ is suffix tree nd tht S relizes τ. If τ cn e relized y string S hving unique end symol, we dditionlly sy tht τ is -suffix tree. See Fig. 1 for n exmple of -suffix tree, suffix tree, nd tree, which is not suffix tree. I et l. [15] recently considered the suffix tree decision prolem nd showed how to decide if τ is -suffix tree in O(n) time, ssuming tht the first letter on ech edge of τ is lso known. Deciding if τ is suffix tree is much more involved, minly ecuse we cn no longer infer the length of string tht relizes τ from the numer of leves. Without n upper ound on the length of such string, it is not even cler how to solve the prolem y n exhustive serch. In this pper, we give such n upper ound, show tht it is tight, nd give liner time lgorithm for deciding if τ is suffix tree. 2 In the literture the stndrd terminology is suffix trees for -suffix trees nd extended/implicit suffix trees [3, 11] for suffix trees of strings not ending with. 2

4 Our Results. In Section 2, we strt y settling the question of the sufficient length of string tht relizes τ. Theorem 1. An unleled tree τ on n nodes is suffix tree if nd only if it is relized y string of length n 1. As fr s we re wre, there were no previous upper ounds on the length of shortest string relizing τ. The ound implies n exhustive serch lgorithm for solving the suffix tree decision prolem, even when the suffix links re not provided. In terms of n, this upper ound is tight, since e.g. strs on n nodes re relized only y strings of length t lest n 1. The min prt of the pper is devoted to the suffix tree decision prolem. We generlize the work of I et l. [15] nd show in Section 4 how to decide if τ is suffix tree. Theorem 2. Let τ e tree with n nodes, nnotted with suffix links of internl nodes nd the first letter on ech edge. There is n O(n) time lgorithm for deciding if τ is suffix tree. In cse τ is suffix tree, the lgorithm lso outputs string S tht relizes τ. To otin the result, we show severl new properties of suffix trees, which my e of independent interest. Relted Work. The prolem of reveling structurl properties nd exploiting them to recover string relizing dt structure hs received lot of ttention in the literture. Besides -suffix trees, the prolem hs een considered for order rrys [17, 7], prmeterized order rrys [12, 13, 14], suffix rrys [2, 9, 16], KMP filure tles [8, 10], prefix tles [5], cover rrys [6], directed cyclic word grphs [2], nd directed cyclic susequence grphs [2]. 2. Suffix Trees In this section we prove Theorem 1 nd some new properties of suffix trees, which we will need to prove Theorem 2. We strt y riefly recpitulting the most importnt definitions. The suffix tree of string S is compcted trie on suffixes of S [11]. Brnching nodes nd leves of the tree re clled explicit nodes, nd positions on edges re clled implicit nodes. The lel of node v is the string lelling the pth from the root to v, nd the length of this lel is clled the string depth of v. The suffix link of n internl explicit node v leled y m is pointer to the node u leled y m. We use the nottion v u nd extend the definition of suffix links to leves nd implicit nodes s well. We will refer to nodes tht re leled y suffixes of S s suffix nodes. All leves of the suffix tree re suffix nodes, nd unless S ends with unique symol, some implicit nodes nd internl explicit nodes cn e suffix nodes s well. Suffix links for suffix nodes form pth strting t the lef leled y S nd ending t the root. Following [4], we cll this pth the suffix chin. 3

5 Lemm 1 ([4]). The suffix chin of the suffix tree cn e prtitioned into the following consecutive segments: (1) Leves; (2) Implicit suffix nodes on lef edges; (3) Implicit suffix nodes on internl edges; nd (4) Suffix nodes tht coincide with internl explicit nodes. (See Fig. 2.) We define the prent pr(x) of node x to e the deepest explicit node on the pth from the root to x. The distnce etween node nd one of its ncestors is defined to e the difference etween the string depths of these nodes. Lemm 2. If x 1 x 2 is suffix link, then the distnce from x 1 to pr(x 1 ) cnnot e less thn the distnce from x 2 to pr(x 2 ). Proof. The string depth of x 2 is smller thn the string depth of x 1 y one. The end of the suffix link from pr(x 2 ) is n ncestor of x 2 nd its string depth is smller thn the string depth of pr(x 1 ) y one gin. Hence, the distnce etween x 1 nd pr(x 1 ) is equl to the distnce etween x 2 nd one of its ncestors, which is t lest the distnce etween x 2 nd pr(x 2 ). Lemm 3. Let x e n implicit suffix node. The distnce etween x nd pr(x) is not igger thn the length of ny lef edge. Proof. It follows from Lemm 2 tht s the suffix chin y 0 y 1... y l = root is trversed, the distnce from ech node to its prent is non-incresing. Since the leves re visited first, the distnce etween ny implicit suffix node nd its prent cnnot exceed the length of lef edge. Lemm 4. If τ is suffix tree, then it cn e relized y some string such tht (1) The miniml length of lef edge of τ will e equl to one; (2) Any edge of τ will contin t most one implicit suffix node t the distnce one from its upper end. Proof. Let S e string relizing τ, nd m e the miniml length of lef edge of τ. Consider prefix S of S otined y deleting its lst (m 1) letters. Its suffix tree is exctly τ trimmed t height m 1. The miniml length of lef edge of this tree is one. Applying Lemm 3, we otin tht the distnce etween ny implicit suffix node x of this tree nd pr(x) is one, nd, consequently, ny edge contins t most one implicit suffix node. Figure 2: The suffix tree τ of string S = with suffix nodes nd the suffix chin. Suffix links of internl nodes re not shown. 4

6 Lemm 5. If τ is relized y string of length l, then it is lso relized y strings of ny length lrger thn l. Proof. Let y 0 y 1... y l = root e the suffix chin for string S tht relizes τ. Moreover let letters(y i ) e the set of first letters immeditely elow node y i. Then letters(y i 1 ) letters(y i ), i = 1,..., l. Let y j e the first non-lef node in the suffix chin (possily the root). It follows tht S lso relizes τ, where is ny letter in letters(y j ). Theorem 1. An unleled tree τ on n nodes is suffix tree if nd only if it is relized y string of length n 1. Proof. It suffices to show tht if τ is suffix tree then there is string of length n 1 tht relizes it. By Lemm 4, τ cn e relized y string S so tht the miniml length of lef edge is 1. Consider the lst lef l visited y the suffix chin in the suffix tree of S. By the property of S the length of the edge (pr(l) l) is 1. Rememer tht suffix link of n internl node lwys points to n internl node nd tht suffix links cnnot form cycles. Moreover, upon trnsition y suffix link the string depth decreses exctly y one. Hence if τ hs I internl nodes then the string depth of the prent of l is t most I 1 nd the string depth of l is t most I. Consequently, if L is the numer of leves in τ, the length of the suffix chin nd thus the length of S is t most L + I 1 = n 1, so y Lemm 5 there is string of this length tht relizes τ. 3. Suffix Tour Grph In their work [15] I et l. introduced notion of suffix tour grphs. They showed tht suffix tour grphs of -suffix trees must hve nice structure which ties together the suffix links of the internl nodes, the first letters on edges, nd the order of leves of τ i.e., which lef corresponds to the longest suffix, which lef corresponds to the second longest suffix, nd so on. Knowing this order nd the first letters on edges outgoing from the root, it is esy to infer string relizing τ. We study the structure of suffix tour grphs of suffix trees. We show connection etween suffix tour grphs of suffix trees nd -suffix trees nd use it to solve the suffix tree decision prolem. Let us first formlize the input to the prolem. Consider tree τ = (V, E) nnotted with set of suffix links σ : V V etween internl explicit nodes, nd the first letter on ech edge, given y lelling function λ : E Σ for some lphet Σ. For ese of description, we will lwys ugment τ with n uxiliry node, the prent of the root. We dd the suffix link (root ) to σ nd lel the edge ( root) with symol?, which mtches ny letter of the lphet. To construct the suffix tour of τ, we first compute vlues l(x) nd d(x) for every explicit node x in τ. The vlue l(x) is equl to the numer of leves y where pr(y) pr(x) is suffix link in σ, nd λ(pr(y) y) = λ(pr(x) x). Let L x nd V x e the sets of leves nd nodes, respectively, of the sutree of 5

7 ? x x y 2 y 2 y 1 y 1 () () Figure 3: () An input consisting of tree, suffix links nd the first letter on ech edge extended with the uxiliry node. () The corresponding suffix tour grph. The input () is the -suffix tree of string, which corresponds to n Euler tour of (). x y 2 y 1 Figure 4: A frgment of the input tree ove. For the node x we hve l(x) = 2, ecuse the prent of x is the endpoint of the suffix links for the prents of leves y 1 nd y 2. For ll other nodes in the sutree of x the l-vlues re equl to zero (no suffix links end t x or elow). Since there re three leves in the sutree of x, we hve d(x) = 1. Consequently, in the suffix tour grph (see Fig. 3) x will hve three incoming rcs: one from y 1, one from y 2, nd one from the prent of x. τ rooted t node x. Note tht L x is suset of V x. We define d(x) = L x y V x l(y). Definition 1. The suffix tour grph of tree τ = (V, E) is directed grph G = (V, E G ), where E G = {(y x) k (y x) E, k = d(x)} {(y x) y is lef contriuting to l(x)}. If k = d(x) < 0, we define (y x) k to e (x y) k. (See Fig. 3 nd Fig. 4 for n exmple.) Below we show tht suffix tour grphs of suffix trees re Eulerin grphs. The proof follows the lines of the proof of similr clim for -suffix trees [15], ut we revise it here for completeness nd ecuse of different nottion. Lemm 6 ([15]). The suffix tour grph G of suffix tree τ is n Eulerin grph (possily disconnected). Proof. To prove the lemm it suffices to show tht for every node the numer of incoming edges equls the numer of outgoing edges. Consider n internl node x of τ. It hs z children(x) d(z) outgoing edges nd l(x) + d(x) incoming edges. But, l(x) + d(x) equls 6

8 ? () () Figure 5: () An input consisting of tree, suffix links nd the first letter on ech edge. The input is the suffix tree of extended with the uxiliry node. () The corresponding suffix tour grph. L x y V x\{x} l(y) = z children(x) ( Lz ) l(y) = y V z z children(x) d(z) Now consider lef y of τ. The outdegree of y is one, nd the indegree is equl to l(x) + d(x) = l(x) + 1 l(x) = Suffix tour grph of -suffix tree The following proposition follows from the definition of -suffix tree. Proposition 1 ([15]). If τ is -suffix tree with set of suffix links σ nd first letters on edges defined y lelling function λ, then (1) For every internl explicit node x in τ there exists unique pth x = x 0 x 1... x k = root such tht x i x i+1 elongs to σ for ll i; (2) If y is the end of the suffix link for pr(x), there is child z of y such tht λ(pr(x) x) = λ(y z), nd the end of the suffix link for x elongs to the sutree of τ rooted t y; (3) For ny node x V the vlue d(x) 0. If ll tree conditions hold, it cn e shown tht Lemm 7 ([15]). The tree τ is -suffix tree iff its suffix tour grph G contins cycle C which goes through the root nd ll leves of τ. Moreover, string relizing τ cn e inferred from C in liner time. In more detil, the uthors of [15] proved tht the order of leves in the cycle C corresponds to the order of suffixes. Tht is, the i th lef fter the root corresponds to the i th longest suffix. Thus, the string cn e reconstructed in liner time: its i th letter will e equl to the first letter on the edge in the pth from the root to the i th lef. Note tht the cycle nd hence the string is not necessrily unique. See Fig. 3 for n exmple. 7

9 ? s t s t () () Figure 6: () The -suffix tree of. () The corresponding suffix tour grph. Lels s nd t mrk the deepest -lef nd the twist node, respectively Suffix tour grph of suffix tree The high level ide of our solution is to try to ugment the input tree so tht the ugmented tree is -suffix tree. More precisely, we will try to ugment the suffix tour grph of the tree to otin suffix tour grph of -suffix tree. It will e essentil to understnd how the suffix tour grphs of suffix trees nd -suffix trees re relted. Let ST nd ST e the suffix tree nd the -suffix tree of string. We cll lef of ST -lef if the edge ending t it is leled y single letter. Note tht to otin ST from ST we must dd ll -leves, their prents, nd suffix links etween the consecutive prents to ST. We denote the deepest -lef y s. (See Fig. 6.) An internl node x of suffix tour grph hs d(x) incoming rcs produced from edges nd l(x) incoming rcs produced from suffix links. All rcs outgoing from x re produced from edges, nd there re d(x) + l(x) of them since suffix tour grphs re Eulerin grphs. A lef x of suffix tour grph hs d(x) incoming rcs produced from edges, l(x) incoming rcs produced from suffix links, nd one outgoing rc produced from suffix link. Below we descrie wht hppens to the vlues d(x) nd l(x), nd to the outgoing rcs produced from suffix links. These two things define the chnges to the suffix tour grph. Lemm 8. For the deepest -lef s we hve l(s) = 0 nd d(s) = 1. The l- vlues of other -leves re equl to one, nd their d-vlues re equl to zero. (See Fig. 6.) Proof. Suppose tht l(s) = 1. Then there is lef y such tht pr (y) pr (s) is suffix link in σ, nd the first letter on the edge from pr (y) to y is. Tht is, y is -lef nd its string depth is igger thn the string depth of s, which is contrdiction. Hence, l(s) = 0 nd therefore d(s) = 1. The prent of ny other -lef y will hve n incoming suffix link from the prent of the previous -lef nd hence l(y) = 1 nd d(y) = 0. 8

10 The importnt consequence of Lemm 8 is tht in the suffix tour grph of ST ll the -leves re connected y pth strting in the deepest -lef nd ending in the root. (See Fig. 6.) Next, we consider nodes tht re explicit in ST nd ST. If node x is explicit in oth trees, we denote its (explicit) prent in ST y pr(x) nd in ST y pr (x). Below in this section we ssume tht ech edge of ST contins t most one implicit suffix node t distnce one from its prent. Lemm 9. Consider node x of ST. If lef y contriutes to l(x) either in ST or ST, nd pr (y) nd pr (x) re either oth explicit or oth implicit in ST, then y contriutes to l(x) in oth trees. Proof. If pr (y) nd pr (x) re explicit, the clim follows strightforwrdly. Consider now the cse when pr (y) nd pr (x) re implicit. Suppose first tht y contriutes to l(x) in ST. Then the lels of pr (y) nd pr (x) re L nd L[2..] for some string L nd letter. Rememer tht distnces etween pr (y) nd pr(y) nd etween pr (x) nd pr(x) re equl to one. Therefore, lels of pr(y) nd pr(x) re L nd L[2..], nd the first letters on edges pr(x) x nd pr(y) y re equl to. Consequently, pr(y) pr(x) is suffix link, nd y contriutes to l(x) in ST s well. Now suppose tht y contriutes to l(x) in ST. Then the lels of pr(y) nd pr(x) re L nd L[2..], nd the first letters on the edges pr(y) y nd pr(x) x re equl to some letter. This mens tht the lels of pr (y) nd pr (x) re L nd L[2..], nd hence there is suffix link from pr (y) to pr (x). Since y nd x re not -leves, y contriutes to l(x) in ST. Before we define the deepest -lef s. If the prent of s is implicit in ST, the chnges etween ST nd ST re more involved. To descrie them, we first need to define the twist node. Let p e the deepest explicit prent of ny -lef in ST. The node tht precedes p in the suffix chin is thus n implicit node in ST, i.e., it hs two children in ST, one which is -lef nd nother node is y, which is either lef or n internl node. If y is lef, let t e the child of p such tht y contriutes to l(t). We refer to t s the twist node. (See Fig. 6.) Lemm 10. Let x e node of ST. Upon trnsition from ST to ST, the l- vlue of x = t increses y one nd the l-vlue of its prent decreses y one. If pr (x) is n implicit node of ST, then l(x) decreses y l(pr (x)). Otherwise, l(x) does not chnge. Proof. The vlue l(x) cn chnge when (1) A lef y contriutes to l(x) in ST, ut not in ST ; or (2) A lef y contriutes to l(x) in ST, ut not in ST. In the first cse the nodes pr (y) nd pr (x) cnnot e oth explicit or oth implicit. Moreover, from the properties of suffix links we know tht if pr (y) is explicit in ST, then pr (x) is explicit s well [11]. Consequently, pr (y) is implicit in ST, nd pr (x) is explicit. Since pr (x) is the first explicit suffix node nd y is lef tht contriutes to l(x), we hve x = t, nd l(x) = l(t) in ST is igger thn l(t) in ST y one (see Fig. 7). 9

11 pr(y) pr(y) pr(x) pr (y) c pr(t) pr (y) c pr (t) pr (x) y t y t y x y x () () Figure 7: Both figures show ST on the left nd ST on the right. Arcs of the suffix tour grphs tht chnge ecuse of the twist node t (Fig. 7) nd ecuse of n implicit prent (Fig. 7) re the grey dshed rcs. Consider one of the leves y stisfying (2). In this cse pr(y) pr(x) is suffix link, nd the first letters on the edges pr(y) y nd pr(x) x re equl. Since y does not contriute to l(x) in ST, exctly one of the nodes pr (y) nd pr (x) must e implicit in ST. Hence, we hve two sucses: (2) pr (y) is implicit in ST, nd pr (x) is explicit; (2) pr (y) is explicit in ST, nd pr (x) is implicit. In the sucse (2) the distnce etween pr(y) nd pr (y) is one. The end of the suffix link for pr (y) must elong to the sutree rooted t x. From the other hnd, the string distnce from pr(x) to the end of the suffix link is one. This mens tht the end of the suffix link is x. Consequently, x is the prent of the twist node t, nd the vlue l(x) = l(pr (t)) is smller y one in ST (see Fig. 7). In the sucse (2) the l-vlue of x in ST is igger thn the l-vlue of x in ST y l(pr (x)), s ll leves contriuting to pr (x) in ST, e.g. y, switch to x in ST (see Fig. 7). Lemm 11. Let x e node of ST. Upon trnsition from ST to ST, the vlue d(x) of node x such tht pr (x) is implicit in ST increses y l(pr (x)). If x is the twist node t, its d-vlue decreses y one. Finlly, the d-vlues of ll ncestors of the deepest -lef s increse y one. Proof. Rememer tht d(x) = L x y V x l(y). If pr (x) is implicit in ST, l(x) decreses y l(pr (x)), i.e. d(x) increses y l(pr (x)). Note tht d- vlues of ncestors of x re not ffected since for them the decrese of l(x) is compensted y the presence of pr (x). The vlue l(t) increses y one nd results in decrese of d(t) y one, ut for other ncestors of t increse of l(t) will e compensted y decrese of l(pr (t)). The vlue l(s) = 0 nd the l-vlues of other -leves re equl to one. Consequently, when we dd the -leves to ST, d-vlues of ncestors of s increse y one, nd d-vlues of ncestors of other -leves re not ffected. Lemm 12. Let pr (x) e n implicit prent of node x ST. Then d(pr (x)) in ST is equl to d(x) in ST if the node pr (x) is not n ncestor of s, nd d(x) + 1 otherwise. 10

12 Proof. First consider the cse when pr (x) is not n ncestor of s. Rememer tht the suffix tour grph is n Eulerin grph. The node pr (x) hs l(pr (x)) incoming rcs produced from suffix links nd d(x) outgoing rcs produced from edges. Hence it must hve d(x) l(pr (x)) incoming rcs produces from edges, nd this is equl to d(x) in ST. If pr (x) is n ncestor of s, the d-vlue must e incresed y one s in the previous lemm. Speking in terms of suffix tour grphs, we mke locl chnges when the node is the twist node t or when the prent of node is implicit in ST, nd dd cycle from the root to s (increse of d-vlues of ncestors of s) nd ck vi ll -leves. 4. Decision Algorithm We re now redy to show the min result of this pper: A liner-time lgorithm tht decides if given tree is suffix tree. Theorem 2. Let τ e tree with n nodes, nnotted with suffix links of internl nodes nd the first letter on ech edge. There is n O(n) time lgorithm for deciding if τ is suffix tree. Proof. We replce the originl prolem with the following one: Cn τ e ugmented to ecome -suffix tree? We ssume tht τ stisfies Oservtion 1(1) nd Oservtion 1(2), which cn e verified in liner time. We will not violte these conditions while ugmenting τ. Rememer tht Oservtion 1(1) gurntees tht for ech node there is unique suffix link pth going from it to the root. We strt y computing lengths of suffix links pths for ech node, which cn e done in liner time. If τ is suffix tree, the lengths re equl to the string depths of the nodes. The deepest -lef s cn either hng from node of τ, or from n implicit suffix node pr (s) on n edge of τ. Furthermore, if τ is suffix tree, then we cn ssume tht it hs ll the properties descried in Lemm 4. Consequently, if pr (s) is implicit in τ, the distnce from pr (s) to the upper end of the edge is equl to one. Tht is, there re O(n) possile loctions of s. For ech of the loctions we consider suffix link pth strting t its prent. The suffix link pths form tree which we refer to s the suffix link tree. The suffix link tree cn e uilt in liner time: For explicit loctions the pths lredy exist, nd for implicit loctions we cn uild the pths following the suffix link pth from the upper end of the edge contining loction nd exploiting the knowledge out lengths of internl edges. If we see node encountered efore, the lgorithm stops. If τ is suffix tree, then it is possile to ugment it so tht its suffix tour grph will stisfy Oservtion 1(3) nd Lemm 7. We remind tht Oservtion 1(3) sys tht for ny node x of the suffix tour grph d(x) 0, nd Lemm 7 sys tht the suffix tour grph contins cycle going through the root nd ll leves. We show tht ech of the conditions cn e verified for ll possile wys 11

13 to ugment τ y liner time trverse of τ or the suffix link tree. We strt with Oservtion 1(3). Lemm 13. If τ cn e ugmented to ecome -suffix tree, then for ll nodes x we hve d(x) 1. Proof. The vlue d(x) increses only when x is n ncestor of s or when pr (x) is implicit in ST. In the first cse it increses y one. Consider the second cse. Rememer tht d(pr (x)) is equl to d(x) or to d(x) + 1 if it is n ncestor of s. Since in -suffix tree ll d-vlues re non-negtive, we hve d(x) 1 for ny node x. Step 1. We first compute ll d-vlues nd ll l-vlues. If d(x) 2 for some node x of τ, then τ cnnot e ugmented to ecome -suffix tree nd hence it is not suffix tree. From now on we ssume tht τ does not contin such nodes. All nodes x with d(x) = 1, except for t most one, must e ncestors of s. If there is node with negtive d-vlue tht is not n ncestor of s, then it must e the lower end of the edge contining pr (s), nd the d-vlue must ecome non-negtive fter we ugment τ. We find the deepest node x with d(x) = 1 y liner time trverse of τ. All nodes with negtive d-vlues must e its ncestors, which cn e verified in liner time. If this is not the cse, τ is not suffix tree. Otherwise, the possile loctions for the prent of s re descendnts of x nd the implicit loction on the edge to x if d(x) + l(x), the d-vlue of x fter ugmenttion, is t lest zero. We cross out ll other loctions. Remrk 1. Given two nodes of τ we cn determine if one is n ncestor of the other in constnt time fter stndrd liner-time preprocessing of τ. Step 2. For ech of the remining loctions we consider the suffix link pth strting t its prent. If the implicit node q preceding the first explicit node p in the pth elongs to lef edge then the twist node t is present in τ nd will e child of p. We cnnot tell which child though, since we do not know the first letter on the lef edge outgoing from q. However, we know tht d(t) decreses y 1 fter ugmenttion, nd hence d(t) must e t lest 0. Moreover, if d(t) = 0 the twist node t must e n ncestor of s to compenste for the decrese of d(t) ( ). For ech of the loctions of s we check if t exists, nd if it does, we find the prent of t. This cn e done in liner time y trverse of the suffix link tree. We then select the loctions of s such tht the prent of t is n ncestor of s or it hs t lest one child stisfying ( ). This cn e done in liner time s well. Step 3. We ssume tht the suffix tour grph of τ is n Eulerin grph, otherwise τ is not suffix tree y Lemm 7. This condition cn e verified in liner time. When we ugment τ, we dd cycle C from the root to the deepest -lef s nd ck vi -leves. The resulting grph will e n Eulerin grph s well, nd one of its connected components (cycles) must contin the root nd ll leves of τ. 12

14 We divide C into three segments: the pth from from the root to the prent pr(x) of the deepest node x with d(x) = 1, the pth from pr(x) to s, nd the pth from s to the root. We strt y dding the first segment to the suffix tour grph. This segment is present in the cycle C for ny choice of s, nd it might ctully increse the numer of connected components in the grph. (Rememer tht if C contins n edge x y nd the grph contins n edge y x, then the edges eliminte ech other.) The second segment cnnot eliminte ny edges of the grph, nd if it touches connected component then ll its nodes re dded to the component contining the root of τ. Since the third segment contins the -leves only, the second segment must go through ll connected components tht contin leves of τ. We pint nodes of ech of the components into some color. And then we perform depth-first trverse of τ mintining counter for ech color nd the totl numer of distinct colors on the pth from the root to the current node. When color counter ecomes equl to zero, we decrese the totl numer of colors y one, nd when color counter ecomes positive, we increse the totl numer of colors y one. If possile loction of s hs ncestors of ll colors, we keep it. Lemm 14. The tree τ is suffix tree iff there is survived loction of s. Proof. If there is such loction, then for ny x in the suffix tour grph of the ugmented tree we hve d(x) 0 nd there is cycle contining the root nd ll leves. We re still to pply the locl chnges cused y implicit prents. Nmely, for ech node x with n implicit prent the edge from y to x is to e replced y the pth y, pr (x), x (see Fig. 7). The cycle cn e re-routed to go vi the new pths insted of the edges, nd it will contin the root nd the leves of τ. Hence, the ugmented tree is -suffix tree nd τ is suffix tree. If τ is suffix tree, then it cn e ugmented to ecome -suffix tree. The prent of s will survive the selection process. Suppose tht there is such loction. Then we cn find the prent of the twist node t if the twist node exists. It must hve child tht stisfies ( ), nd we choose this child to e the twist node t. Let the first letter on the edge to the twist node e. Then we put the first letter on ll new lef edges cused y the implicit nodes equl to. The resulting grph will e the suffix tour grph of -suffix tree. We cn use the solution of I et. l [15] to reconstruct string S relizing this -suffix tree in liner time. The tree τ will e suffix tree of the string S. This completes the proof of Theorem Conclusions nd Open Prolems We hve proved severl new properties of suffix trees, including n upper ound of n 1 on the length of shortest string S relizing suffix tree τ with n nodes. As noted this ound is tight in terms of n, since the numer of leves in τ, which cn e n 1, provides trivil lower ound on the length of S. Using these properties, we hve shown how to decide if tree τ with n nodes is suffix tree in O(n) time, provided tht the suffix links of internl nodes nd 13

15 the first letter on ech edge is specified. It remins n interesting open question whether the prolem cn e solved without first letters or, even, without suffix links (i.e., given only the tree structure). Our results imply tht the set of ll -suffix trees is proper suset of the set ll of suffix trees (e.g., the suffix tree of string is not -suffix tree (see Fig. 5 nd Lemm 7), which in turn is proper suset of the set of ll trees (consider, e.g., Fig. 1c or simply pth of length 2). References [1] Alerto Apostolico, Mxime Crochemore, Mrtin Frch-Colton, Zvi Glil, nd S. Muthukrishnn. Forty Yers of Text Indexing. In Proc. 24th CPM (LNCS 7922), pges [2] Hideo Bnni, Shunsuke Ineng, Ayumi Shinohr, nd Msyuki Tked. Inferring strings from grphs nd rrys. In Proc. 28th MFCS (LNCS 2747), volume 2747, pges , [3] Dny Bresluer nd Rmesh Hrihrn. Optiml prllel construction of miniml suffix nd fctor utomt. Prllel Process. Lett., 06(01):35 44, [4] Dny Bresluer nd Giuseppe F. Itlino. On suffix extensions in suffix trees. Theor. Comp. Sci., 457:27 34, [5] Julien Clément, Mxime Crochemore, nd Giuseppin Rindone. Reverse engineering prefix tles. In Proc. 26th STACS, pges , [6] Mxime Crochemore, Costs S. Iliopoulos, Solon P. Pissis, nd Germn Tischler. Cover rry string reconstruction. In Proc. 21st CPM (LNCS 6129), pges , [7] Jen-Pierre Duvl, Thierry Lecroq, nd Arnud Lefevre. Border rry on ounded lphet. J. Autom. Lng. Com., 10(1):51 60, [8] Jen-Pierre Duvl, Thierry Lecroq, nd Arnud Lefevre. Efficient vlidtion nd construction of order rrys nd vlidtion of string mtching utomt. RAIRO Theor. Inform. Appl., 43: , [9] Jen-Pierre Duvl nd Arnud Lefevre. Words over n ordered lphet nd suffix permuttions. RAIRO Theor. Inform. Appl., 36(3): , [10] Pwe l Gwrychowski, Artur Jeż, nd Luksz Jeż. Vlidting the Knuth- Morris-Prtt filure function, fst nd online. Theory Comput. Syst., 54(2): , [11] D. Gusfield. Algorithms on Strings, Trees nd Sequences: Computer Science nd Computtionl Biology. Cmridge University Press,

16 [12] Tomohiro I, Shunsuke Ineng, Hideo Bnni, nd Msyuki Tked. Counting prmeterized order rrys for inry lphet. In Proc. LATA (LNCS 5457), pges , [13] Tomohiro I, Shunsuke Ineng, Hideo Bnni, nd Msyuki Tked. Verifying Prmeterized Border Arry in O(n 1.5 ) Time. In Proc. 21st CPM (LNCS 6129), pges , [14] Tomohiro I, Shunsuke Ineng, Hideo Bnni, nd Msyuki Tked. Verifying nd enumerting prmeterized order rrys. Theor. Comput. Sci., 412(50): , [15] Tomohiro I, Shunsuke Ineng, Hideo Bnni, nd Msyuki Tked. Inferring strings from suffix trees nd links on inry lphet. Discrete Appl. Mth., 163: , [16] Gregory Kucherov, Lill Tóthmérész, nd Stéphne Vilette. On the comintorics of suffix rrys. Inf. Process. Lett., 113(22-24): , [17] Weilin Lu, P. J. Ryn, W. F. Smyth, Yu Sun, nd Lu Yng. Verifying order rry in liner time. J. Com. Mth. Com. Comput., 42: , [18] Esko Ukkonen. On-line construction of suffix trees. Algorithmic, 14(3): , [19] Peter Weiner. Liner pttern mtching lgorithms. In Proc. 14th FOCS (SWAT), pges 1 11,

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

On Suffix Tree Breadth

On Suffix Tree Breadth On Suffix Tree Bredth Golnz Bdkoeh 1,, Juh Kärkkäinen 2, Simon J. Puglisi 2,, nd Bell Zhukov 2, 1 Deprtment of Computer Science University of Wrwick Conventry, United Kingdom g.dkoeh@wrwick.c.uk 2 Helsinki

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

The size of subsequence automaton

The size of subsequence automaton Theoreticl Computer Science 4 (005) 79 84 www.elsevier.com/locte/tcs Note The size of susequence utomton Zdeněk Troníček,, Ayumi Shinohr,c Deprtment of Computer Science nd Engineering, FEE CTU in Prgue,

More information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

More information

p-adic Egyptian Fractions

p-adic Egyptian Fractions p-adic Egyptin Frctions Contents 1 Introduction 1 2 Trditionl Egyptin Frctions nd Greedy Algorithm 2 3 Set-up 3 4 p-greedy Algorithm 5 5 p-egyptin Trditionl 10 6 Conclusion 1 Introduction An Egyptin frction

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

Bases for Vector Spaces

Bases for Vector Spaces Bses for Vector Spces 2-26-25 A set is independent if, roughly speking, there is no redundncy in the set: You cn t uild ny vector in the set s liner comintion of the others A set spns if you cn uild everything

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University U.U.D.M. Project Report 07:4 Frey Frctions Rickrd Fernström Exmensrete i mtemtik, 5 hp Hledre: Andres Strömergsson Exmintor: Jörgen Östensson Juni 07 Deprtment of Mthemtics Uppsl University Frey Frctions

More information

Solving the String Statistics Problem in Time O(n log n)

Solving the String Statistics Problem in Time O(n log n) Alcom-FT Technicl Report Series ALCOMFT-TR-02-55 Solving the String Sttistics Prolem in Time O(n log n) Gerth Stølting Brodl 1,,, Rune B. Lyngsø 3, Ann Östlin1,, nd Christin N. S. Pedersen 1,2, 1 BRICS,

More information

1 From NFA to regular expression

1 From NFA to regular expression Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

More information

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3 2 The Prllel Circuit Electric Circuits: Figure 2- elow show ttery nd multiple resistors rrnged in prllel. Ech resistor receives portion of the current from the ttery sed on its resistnce. The split is

More information

Name Ima Sample ASU ID

Name Ima Sample ASU ID Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

2.4 Linear Inequalities and Interval Notation

2.4 Linear Inequalities and Interval Notation .4 Liner Inequlities nd Intervl Nottion We wnt to solve equtions tht hve n inequlity symol insted of n equl sign. There re four inequlity symols tht we will look t: Less thn , Less thn or

More information

Homework Solution - Set 5 Due: Friday 10/03/08

Homework Solution - Set 5 Due: Friday 10/03/08 CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution - et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte non-finl.

More information

Lecture 3: Equivalence Relations

Lecture 3: Equivalence Relations Mthcmp Crsh Course Instructor: Pdric Brtlett Lecture 3: Equivlence Reltions Week 1 Mthcmp 2014 In our lst three tlks of this clss, we shift the focus of our tlks from proof techniques to proof concepts

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

Suppose we want to find the area under the parabola and above the x axis, between the lines x = 2 and x = -2.

Suppose we want to find the area under the parabola and above the x axis, between the lines x = 2 and x = -2. Mth 43 Section 6. Section 6.: Definite Integrl Suppose we wnt to find the re of region tht is not so nicely shped. For exmple, consider the function shown elow. The re elow the curve nd ove the x xis cnnot

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

Section 6.1 Definite Integral

Section 6.1 Definite Integral Section 6.1 Definite Integrl Suppose we wnt to find the re of region tht is not so nicely shped. For exmple, consider the function shown elow. The re elow the curve nd ove the x xis cnnot e determined

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016 CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

CM10196 Topic 4: Functions and Relations

CM10196 Topic 4: Functions and Relations CM096 Topic 4: Functions nd Reltions Guy McCusker W. Functions nd reltions Perhps the most widely used notion in ll of mthemtics is tht of function. Informlly, function is n opertion which tkes n input

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

Hamiltonian Cycle in Complete Multipartite Graphs

Hamiltonian Cycle in Complete Multipartite Graphs Annls of Pure nd Applied Mthemtics Vol 13, No 2, 2017, 223-228 ISSN: 2279-087X (P), 2279-0888(online) Pulished on 18 April 2017 wwwreserchmthsciorg DOI: http://dxdoiorg/1022457/pmv13n28 Annls of Hmiltonin

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Improper Integrals. The First Fundamental Theorem of Calculus, as we ve discussed in class, goes as follows:

Improper Integrals. The First Fundamental Theorem of Calculus, as we ve discussed in class, goes as follows: Improper Integrls The First Fundmentl Theorem of Clculus, s we ve discussed in clss, goes s follows: If f is continuous on the intervl [, ] nd F is function for which F t = ft, then ftdt = F F. An integrl

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)

More information

Quadratic Forms. Quadratic Forms

Quadratic Forms. Quadratic Forms Qudrtic Forms Recll the Simon & Blume excerpt from n erlier lecture which sid tht the min tsk of clculus is to pproximte nonliner functions with liner functions. It s ctully more ccurte to sy tht we pproximte

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives Block #6: Properties of Integrls, Indefinite Integrls Gols: Definition of the Definite Integrl Integrl Clcultions using Antiderivtives Properties of Integrls The Indefinite Integrl 1 Riemnn Sums - 1 Riemnn

More information

Linear Inequalities. Work Sheet 1

Linear Inequalities. Work Sheet 1 Work Sheet 1 Liner Inequlities Rent--Hep, cr rentl compny,chrges $ 15 per week plus $ 0.0 per mile to rent one of their crs. Suppose you re limited y how much money you cn spend for the week : You cn spend

More information

Review of Gaussian Quadrature method

Review of Gaussian Quadrature method Review of Gussin Qudrture method Nsser M. Asi Spring 006 compiled on Sundy Decemer 1, 017 t 09:1 PM 1 The prolem To find numericl vlue for the integrl of rel vlued function of rel vrile over specific rnge

More information

Section 6: Area, Volume, and Average Value

Section 6: Area, Volume, and Average Value Chpter The Integrl Applied Clculus Section 6: Are, Volume, nd Averge Vlue Are We hve lredy used integrls to find the re etween the grph of function nd the horizontl xis. Integrls cn lso e used to find

More information

Torsion in Groups of Integral Triangles

Torsion in Groups of Integral Triangles Advnces in Pure Mthemtics, 01,, 116-10 http://dxdoiorg/1046/pm011015 Pulished Online Jnury 01 (http://wwwscirporg/journl/pm) Torsion in Groups of Integrl Tringles Will Murry Deprtment of Mthemtics nd Sttistics,

More information

The area under the graph of f and above the x-axis between a and b is denoted by. f(x) dx. π O

The area under the graph of f and above the x-axis between a and b is denoted by. f(x) dx. π O 1 Section 5. The Definite Integrl Suppose tht function f is continuous nd positive over n intervl [, ]. y = f(x) x The re under the grph of f nd ove the x-xis etween nd is denoted y f(x) dx nd clled the

More information

Lecture 09: Myhill-Nerode Theorem

Lecture 09: Myhill-Nerode Theorem CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

7.2 The Definite Integral

7.2 The Definite Integral 7.2 The Definite Integrl the definite integrl In the previous section, it ws found tht if function f is continuous nd nonnegtive, then the re under the grph of f on [, b] is given by F (b) F (), where

More information

Designing Information Devices and Systems I Spring 2018 Homework 7

Designing Information Devices and Systems I Spring 2018 Homework 7 EECS 16A Designing Informtion Devices nd Systems I Spring 2018 omework 7 This homework is due Mrch 12, 2018, t 23:59. Self-grdes re due Mrch 15, 2018, t 23:59. Sumission Formt Your homework sumission should

More information

set is not closed under matrix [ multiplication, ] and does not form a group.

set is not closed under matrix [ multiplication, ] and does not form a group. Prolem 2.3: Which of the following collections of 2 2 mtrices with rel entries form groups under [ mtrix ] multipliction? i) Those of the form for which c d 2 Answer: The set of such mtrices is not closed

More information

Section 4: Integration ECO4112F 2011

Section 4: Integration ECO4112F 2011 Reding: Ching Chpter Section : Integrtion ECOF Note: These notes do not fully cover the mteril in Ching, ut re ment to supplement your reding in Ching. Thus fr the optimistion you hve covered hs een sttic

More information

Interpreting Integrals and the Fundamental Theorem

Interpreting Integrals and the Fundamental Theorem Interpreting Integrls nd the Fundmentl Theorem Tody, we go further in interpreting the mening of the definite integrl. Using Units to Aid Interprettion We lredy know tht if f(t) is the rte of chnge of

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

Surface maps into free groups

Surface maps into free groups Surfce mps into free groups lden Wlker Novemer 10, 2014 Free groups wedge X of two circles: Set F = π 1 (X ) =,. We write cpitl letters for inverse, so = 1. e.g. () 1 = Commuttors Let x nd y e loops. The

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Balanced binary search trees

Balanced binary search trees 02110 Inge Li Gørtz Overview Blnced binry serch trees: Red-blck trees nd 2-3-4 trees Amortized nlysis Dynmic progrmming Network flows String mtching String indexing Computtionl geometry Introduction to

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

The Minimum Label Spanning Tree Problem: Illustrating the Utility of Genetic Algorithms

The Minimum Label Spanning Tree Problem: Illustrating the Utility of Genetic Algorithms The Minimum Lel Spnning Tree Prolem: Illustrting the Utility of Genetic Algorithms Yupei Xiong, Univ. of Mrylnd Bruce Golden, Univ. of Mrylnd Edwrd Wsil, Americn Univ. Presented t BAE Systems Distinguished

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

MA123, Chapter 10: Formulas for integrals: integrals, antiderivatives, and the Fundamental Theorem of Calculus (pp.

MA123, Chapter 10: Formulas for integrals: integrals, antiderivatives, and the Fundamental Theorem of Calculus (pp. MA123, Chpter 1: Formuls for integrls: integrls, ntiderivtives, nd the Fundmentl Theorem of Clculus (pp. 27-233, Gootmn) Chpter Gols: Assignments: Understnd the sttement of the Fundmentl Theorem of Clculus.

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information

Lecture 2: January 27

Lecture 2: January 27 CS 684: Algorithmic Gme Theory Spring 217 Lecturer: Év Trdos Lecture 2: Jnury 27 Scrie: Alert Julius Liu 2.1 Logistics Scrie notes must e sumitted within 24 hours of the corresponding lecture for full

More information

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique? XII. LINEAR ALGEBRA: SOLVING SYSTEMS OF EQUATIONS Tody we re going to tlk out solving systems of liner equtions. These re prolems tht give couple of equtions with couple of unknowns, like: 6= x + x 7=

More information

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations.

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations. Lecture 3 3 Solving liner equtions In this lecture we will discuss lgorithms for solving systems of liner equtions Multiplictive identity Let us restrict ourselves to considering squre mtrices since one

More information

Exercises with (Some) Solutions

Exercises with (Some) Solutions Exercises with (Some) Solutions Techer: Luc Tesei Mster of Science in Computer Science - University of Cmerino Contents 1 Strong Bisimultion nd HML 2 2 Wek Bisimultion 31 3 Complete Lttices nd Fix Points

More information

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

More information

W. We shall do so one by one, starting with I 1, and we shall do it greedily, trying

W. We shall do so one by one, starting with I 1, and we shall do it greedily, trying Vitli covers 1 Definition. A Vitli cover of set E R is set V of closed intervls with positive length so tht, for every δ > 0 nd every x E, there is some I V with λ(i ) < δ nd x I. 2 Lemm (Vitli covering)

More information

UNIFORM CONVERGENCE. Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3

UNIFORM CONVERGENCE. Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3 UNIFORM CONVERGENCE Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3 Suppose f n : Ω R or f n : Ω C is sequence of rel or complex functions, nd f n f s n in some sense. Furthermore,

More information

The maximal number of runs in standard Sturmian words

The maximal number of runs in standard Sturmian words The miml numer of runs in stndrd Sturmin words Pwe l Bturo Mrcin Piątkowski Wojciech Rytter Fculty of Mthemtics nd Computer Science Nicolus Copernicus University Institute of Informtics Wrsw University

More information

Free groups, Lecture 2, part 1

Free groups, Lecture 2, part 1 Free groups, Lecture 2, prt 1 Olg Khrlmpovich NYC, Sep. 2 1 / 22 Theorem Every sugroup H F of free group F is free. Given finite numer of genertors of H we cn compute its sis. 2 / 22 Schreir s grph The

More information

Discrete Mathematics and Probability Theory Spring 2013 Anant Sahai Lecture 17

Discrete Mathematics and Probability Theory Spring 2013 Anant Sahai Lecture 17 EECS 70 Discrete Mthemtics nd Proility Theory Spring 2013 Annt Shi Lecture 17 I.I.D. Rndom Vriles Estimting the is of coin Question: We wnt to estimte the proportion p of Democrts in the US popultion,

More information

Riemann Sums and Riemann Integrals

Riemann Sums and Riemann Integrals Riemnn Sums nd Riemnn Integrls Jmes K. Peterson Deprtment of Biologicl Sciences nd Deprtment of Mthemticl Sciences Clemson University August 26, 203 Outline Riemnn Sums Riemnn Integrls Properties Abstrct

More information

Vectors , (0,0). 5. A vector is commonly denoted by putting an arrow above its symbol, as in the picture above. Here are some 3-dimensional vectors:

Vectors , (0,0). 5. A vector is commonly denoted by putting an arrow above its symbol, as in the picture above. Here are some 3-dimensional vectors: Vectors 1-23-2018 I ll look t vectors from n lgeric point of view nd geometric point of view. Algericlly, vector is n ordered list of (usully) rel numers. Here re some 2-dimensionl vectors: (2, 3), ( )

More information

Module 9: Tries and String Matching

Module 9: Tries and String Matching Module 9: Tries nd String Mtching CS 240 - Dt Structures nd Dt Mngement Sjed Hque Veronik Irvine Tylor Smith Bsed on lecture notes by mny previous cs240 instructors Dvid R. Cheriton School of Computer

More information

Module 9: Tries and String Matching

Module 9: Tries and String Matching Module 9: Tries nd String Mtching CS 240 - Dt Structures nd Dt Mngement Sjed Hque Veronik Irvine Tylor Smith Bsed on lecture notes by mny previous cs240 instructors Dvid R. Cheriton School of Computer

More information

Riemann Sums and Riemann Integrals

Riemann Sums and Riemann Integrals Riemnn Sums nd Riemnn Integrls Jmes K. Peterson Deprtment of Biologicl Sciences nd Deprtment of Mthemticl Sciences Clemson University August 26, 2013 Outline 1 Riemnn Sums 2 Riemnn Integrls 3 Properties

More information

We partition C into n small arcs by forming a partition of [a, b] by picking s i as follows: a = s 0 < s 1 < < s n = b.

We partition C into n small arcs by forming a partition of [a, b] by picking s i as follows: a = s 0 < s 1 < < s n = b. Mth 255 - Vector lculus II Notes 4.2 Pth nd Line Integrls We begin with discussion of pth integrls (the book clls them sclr line integrls). We will do this for function of two vribles, but these ides cn

More information

Chapter 8.2: The Integral

Chapter 8.2: The Integral Chpter 8.: The Integrl You cn think of Clculus s doule-wide triler. In one width of it lives differentil clculus. In the other hlf lives wht is clled integrl clculus. We hve lredy eplored few rooms in

More information

MTH 505: Number Theory Spring 2017

MTH 505: Number Theory Spring 2017 MTH 505: Numer Theory Spring 207 Homework 2 Drew Armstrong The Froenius Coin Prolem. Consider the eqution x ` y c where,, c, x, y re nturl numers. We cn think of $ nd $ s two denomintions of coins nd $c

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

Math 1B, lecture 4: Error bounds for numerical methods

Math 1B, lecture 4: Error bounds for numerical methods Mth B, lecture 4: Error bounds for numericl methods Nthn Pflueger 4 September 0 Introduction The five numericl methods descried in the previous lecture ll operte by the sme principle: they pproximte the

More information

Recitation 3: More Applications of the Derivative

Recitation 3: More Applications of the Derivative Mth 1c TA: Pdric Brtlett Recittion 3: More Applictions of the Derivtive Week 3 Cltech 2012 1 Rndom Question Question 1 A grph consists of the following: A set V of vertices. A set E of edges where ech

More information

1B40 Practical Skills

1B40 Practical Skills B40 Prcticl Skills Comining uncertinties from severl quntities error propgtion We usully encounter situtions where the result of n experiment is given in terms of two (or more) quntities. We then need

More information

Connected-components. Summary of lecture 9. Algorithms and Data Structures Disjoint sets. Example: connected components in graphs

Connected-components. Summary of lecture 9. Algorithms and Data Structures Disjoint sets. Example: connected components in graphs Prm University, Mth. Deprtment Summry of lecture 9 Algorithms nd Dt Structures Disjoint sets Summry of this lecture: (CLR.1-3) Dt Structures for Disjoint sets: Union opertion Find opertion Mrco Pellegrini

More information

State space systems analysis (continued) Stability. A. Definitions A system is said to be Asymptotically Stable (AS) when it satisfies

State space systems analysis (continued) Stability. A. Definitions A system is said to be Asymptotically Stable (AS) when it satisfies Stte spce systems nlysis (continued) Stbility A. Definitions A system is sid to be Asymptoticlly Stble (AS) when it stisfies ut () = 0, t > 0 lim xt () 0. t A system is AS if nd only if the impulse response

More information

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t

More information

List all of the possible rational roots of each equation. Then find all solutions (both real and imaginary) of the equation. 1.

List all of the possible rational roots of each equation. Then find all solutions (both real and imaginary) of the equation. 1. Mth Anlysis CP WS 4.X- Section 4.-4.4 Review Complete ech question without the use of grphing clcultor.. Compre the mening of the words: roots, zeros nd fctors.. Determine whether - is root of 0. Show

More information

The practical version

The practical version Roerto s Notes on Integrl Clculus Chpter 4: Definite integrls nd the FTC Section 7 The Fundmentl Theorem of Clculus: The prcticl version Wht you need to know lredy: The theoreticl version of the FTC. Wht

More information

7.1 Integral as Net Change and 7.2 Areas in the Plane Calculus

7.1 Integral as Net Change and 7.2 Areas in the Plane Calculus 7.1 Integrl s Net Chnge nd 7. Ares in the Plne Clculus 7.1 INTEGRAL AS NET CHANGE Notecrds from 7.1: Displcement vs Totl Distnce, Integrl s Net Chnge We hve lredy seen how the position of n oject cn e

More information

Advanced Calculus: MATH 410 Notes on Integrals and Integrability Professor David Levermore 17 October 2004

Advanced Calculus: MATH 410 Notes on Integrals and Integrability Professor David Levermore 17 October 2004 Advnced Clculus: MATH 410 Notes on Integrls nd Integrbility Professor Dvid Levermore 17 October 2004 1. Definite Integrls In this section we revisit the definite integrl tht you were introduced to when

More information

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides. 1 PYTHAGORAS THEOREM 1 1 Pythgors Theorem In this setion we will present geometri proof of the fmous theorem of Pythgors. Given right ngled tringle, the squre of the hypotenuse is equl to the sum of the

More information

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

More information

Model Reduction of Finite State Machines by Contraction

Model Reduction of Finite State Machines by Contraction Model Reduction of Finite Stte Mchines y Contrction Alessndro Giu Dip. di Ingegneri Elettric ed Elettronic, Università di Cgliri, Pizz d Armi, 09123 Cgliri, Itly Phone: +39-070-675-5892 Fx: +39-070-675-5900

More information

Handout: Natural deduction for first order logic

Handout: Natural deduction for first order logic MATH 457 Introduction to Mthemticl Logic Spring 2016 Dr Json Rute Hndout: Nturl deduction for first order logic We will extend our nturl deduction rules for sententil logic to first order logic These notes

More information