SlideServe
Menu
Préférences
© SlideServe · v2026

The TRIE

nibaw avatar
14 diapositives · 405 Views · Sep 02, 2014

The TRIE. Amihood Amir . Labeled Trees. Edge Labeled Tree: T=(V,E,ℓ) Where ℓ:V  Σ , Σ is the alphabet. Example: Σ ={ A,B,C }. A. A. B. C. B. Path String.

The TRIE - slide 1
01 / 14The TRIE
1 / 17

Télécharger la présentation

The TRIE
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. The TRIE Amihood Amir

  2. Labeled Trees Edge Labeled Tree: T=(V,E,ℓ) Where ℓ:VΣ, Σis the alphabet. Example: Σ={A,B,C} A A B C B

  3. Path String A pathv0,…,viin an edge labeled tree defines the path string ℓ(v0),…,ℓ(vi)of the labels of the vertices on the path. Example: Path: A A B C B Path string:AAB

  4. Root Paths A root path v0,…,viin an edge labeled tree is a path that starts at the root, i.e. v0 is the root of the tree. Example: Root Path: A Not Root Path: A B C B

  5. Longest Common Prefix Let S=S[1],…,S[m] and T=T[1],…,T[n] be two strings over alphabet Σ. The Longest Common Prefix (LCP) of S and T is the string a[1],…,a[k] such that a[i]=S[i]=T[i], i=1,…,k and such that S[k+1]≠T[k+1]. Example:The LCP of ABCAABCDABCCC and ABCAABCDACACC is: ABCAABCDA

  6. reTRIEval We define a Trie Tof n strings S1 = S1[1],…,S1[m1] S2 = S2[1],…,S2[m2] … Sn = Sn[1],…,Sn[mn] over alphabetΣby induction on n as follows: Let Λ,$єΣ.

  7. reTRIEval – base case Λ For n=1: S1 = S1[1],…,S1[m1] The trie is: S1[1] . . . S1[m1] $

  8. reTRIEval – inductive case (1) Assume we have defined he trie Tn of n strings. The trieTn+1 of the n+1 strings: S1 = S1[1],…,S1[m1] S2 = S2[1],…,S2[m2] … Sn = Sn[1],…,Sn[mn] Sn+1 = Sn+1[1],…,Sn+1[mn+1] Is defined as follows:

  9. reTRIEval - inductive case (2) Let Tn be the trie of the n strings S1 = S1[1],…,S1[m1] S2 = S2[1],…,S2[m2] … Sn = Sn[1],…,Sn[mn] And let a[1],…a[k] be the longest LCP(Sn+1,Si), i=1,…,n.

  10. reTRIEval – inductive case (3) Concatenate the path: To the node where the root path of string a[1],…,a[k] ends. The resulting tree is Tn+1. Sn+1[k+1] . . . Sn+1[mn+1] $

  11. Trie construction Example ABCABC ABB ABBA ABCB BBAB BABC

  12. Trie construction Time For a Trie Tof n strings: S1 = S1[1],…,S1[m1] S2 = S2[1],…,S2[m2] … Sn = Sn[1],…,Sn[mn] Over fixed finite alphabet Σ:

  13. Trie Insertion, Lookup, Deletion Time For string:S = S[1],…,S[m] Over fixed finite alphabet Σ: O(m) Over ubounded alphabet Σ: O(m log n)

  14. How do we deal with numbers? An n-digit number is the string composed of the digits. Insertion/deletion/lookup time of number m:O(log m) Compare with AVL: O(log n)