1 / 18

עבודה סמינריונית Prelude to Ukkonen algorithm ON-LINE CONSTRUCTION OF SUFFIX TREES

עבודה סמינריונית Prelude to Ukkonen algorithm ON-LINE CONSTRUCTION OF SUFFIX TREES. מגישים: עיד מוחמד טיבי פיראס. תוכן ההרצאה. בהרצאה זו נדון בבניית עצי T rie באמצעות אלגוריתם ON-LINE-TRIE .

alize
Download Presentation

עבודה סמינריונית Prelude to Ukkonen algorithm ON-LINE CONSTRUCTION OF SUFFIX TREES

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. עבודה סמינריוניתPrelude to Ukkonen algorithmON-LINE CONSTRUCTION OF SUFFIX TREES מגישים: עיד מוחמד טיבי פיראס

  2. תוכן ההרצאה • בהרצאה זו נדון בבניית עצי Trieבאמצעות אלגוריתם ON-LINE-TRIE. • הבנייה תהיה בנייה הדרגתית, הכוונה היא לבנות עצי ביניים שכל עץ מהן יעזור בבניית העץ שאחריו. (online intermeduate trees)

  3. PREFIXES הגדרה:Piמסמל תת מילה מהטקסט, שמתחילה מהאינדקס 1 ומסתיימת באינדיקסi. P[1..i] • דוגמאות בשקופית הבאה...

  4. דוגמאות על Prefixes text = abba • P¹ = P[1..1] = a • P² = P[1..2] = ab • P³ = P[1..3] = abb • P4 = P[1..4] = P = abba

  5. תזכורת בניית עץ נסיוני (Trie Tree) ל_ text = abaabb Trie(text) הצמתים השחורים נקראים צמתים מהותיים. a b b a b a a a b b b a b b b b

  6. ON-LINE INTERMEDIATE TREES מה הכוונה בבניית ON-LINE INTERMEDIATE TREES? הכוונה לבנות עצי ביניים, שכל עץ מהן עוזר בבניית העץ שאחריו. Trie(P¹), Trie(P²), . . ., Trie(Pn-1) • כדי לבנות עץTrie(P²)נעזרים בעץTrie(P¹)

  7. SUFFIX LINKS • xpהיא מחרוזת. x הוא תו אחד ו_ p היא תת-מילה. • V היא צומת שהתווית שלה xp. אם קיימת צומת S(V) עם תווית p, אז המצביע (V, S(V)) נקרא Suffix Link. Suffix Link S(V) Label[S(V)] = p V Label[V] = xp

  8. SUFFIX LINKS • Suf[root] = root • אם אין צומת S(V)אז suf[V] = nil • Suffix Linksתורמים לבנייתSuffix TreesבזמןO(n).

  9. SUFFIX LINKS • דוגמא: לצומת הזו יש שני בנים {a,b} אי-אפשר להוסיף לה עוד בנים a b b a a a a a

  10. ON-LINE-TRIE ALGORITHM Algorithm on-line-trie; create the two-node tree Trie(text[1]) with suffix links; for i := 2 to n do begin ai:= text[i]; Vi -1 := deepest leaf of Trie(P i -1); k := min{ k : son(suf k[Vi-1], ai) = nil }; create ai-sons for Vi -1, suf[Vi-1], … , suf k-1[Vi-1], and new suffix links for them. end

  11. Creating ai-sons V1 ai Before V2 V1 ai V3 V2 ai V1 V4 V3 ai V2 After V5 V4 ai V3 V5 ai V4 existing suffix links V5 New suffix links created New nodes

  12. רעיון האלגוריתם • בכל איטרציה i עוברים דרך ה_suffix linksמהצומת הכיעמוקה עד לצומת הראשונה ומוסיפיםai-sons. • Vkהואsuffixשל האורךkמ_Pi דוגמא: text = abab, i = 3, k = 2 Pi = aba Vk = suf[ab] = b • הצמתיםVkהן בעצם צמתים מהותיים. • הרצףVi, Vi-1, …, V0מייצג את ה_suffixesשל Piבסדר יורד מבחינת אורכן.

  13. המשך רעיון האלגוריתם • ai = text[i] • Vj הוא הצומת הראשונה ברצף הצמתים המהותיים Vi-1, Vi-2, …, V0 שמקיים child(Vj, ai) = nil, כלומר, שיש לה צומת עם תווית ai. • אם Vjקיים אז העץ Trie(P i) הוא תוצאה של הוספת בנים חדשים עם תווית ai לצמתים: Vi-1, Vi-2, …, Vj+1 • אם Vjלא קיים אז מוסיפים בנים חדשים עם תווית ai לצמתים: Vi-1, Vi-2, …, V0

  14. ON-LINE-TRIE ALGORITHM • הרצת האלגוריתם על הקלט text = abaabb. Trie(P 1) Trie(P 2) המשך ההרצה בדף הבא... a a b P 1 = a a P 2= ab i = 2 ai = b b

  15. ON-LINE-TRIE ALGORITHM Trie(P 3) a b a b b b a P 3 = aba i = 3 ai = a a

  16. ON-LINE-TRIE ALGORITHM Trie(P 4) a b a b b a b a a abaa= P 4 i = 4 ai = a a a a a

  17. ON-LINE-TRIE ALGORITHM Trie(P 5) a a b b b b a a a a P 5 = abaab i = 5 ai = b a a a a b b a a b

  18. ON-LINE-TRIE ALGORITHM Trie(P 6) a b a b b a b a b a a P 6 = abaabb i = 6 ai = b a a a a b b b b b a a b b b b b

More Related