Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2004 Goodrich, Tamassia Tries1 Chapter 7 Tries Topics Basics Standard tries Compressed ( 壓縮 ) tries Suffix ( 尾字 ) tries.

Similar presentations


Presentation on theme: "© 2004 Goodrich, Tamassia Tries1 Chapter 7 Tries Topics Basics Standard tries Compressed ( 壓縮 ) tries Suffix ( 尾字 ) tries."— Presentation transcript:

1 © 2004 Goodrich, Tamassia Tries1 Chapter 7 Tries Topics Basics Standard tries Compressed ( 壓縮 ) tries Suffix ( 尾字 ) tries

2 © 2004 Goodrich, Tamassia Tries2 Basics A trie, a portion ( 部分 ) of word retrieve ( 擷取 ), is a compact ( 簡潔 ) data structure for representing a set of strings ( 字串 ), such as all the words in a text A tries supports pattern ( 圖樣 ) matching ( 比對 ) queries in time proportional ( 正比 ) to the pattern size

3 © 2004 Goodrich, Tamassia Tries3 Standard Tries The standard ( 標準 ) trie for a set of strings S is an ordered ( 次序 ) tree such that: Each node but the root is labeled ( 標記 ) with a character ( 字元 ) The children of a node are alphabetically ( 字母順序 ) ordered The paths from the external nodes to the root yield ( 產出 ) the strings of S Example: standard trie for the set of strings S = { bear, bell, bid, bull, buy, sell, stock, stop }

4 © 2004 Goodrich, Tamassia Tries4 Standard Tries A standard trie uses O(n) space and supports searches, insertions and deletions in time O(dm), where: n total size of the strings in S m size of the string parameter ( 參數 ) of the operation d size of the alphabet ( 字母集 )

5 © 2004 Goodrich, Tamassia Tries5 Standard Tries - Applications We insert the words of the text into a trie Each leaf ( 樹 葉 ) stores the occurrences ( 發生點 ) of the associated word in the text

6 © 2004 Goodrich, Tamassia Tries6 Compressed Tries A compressed trie has internal nodes of degree ( 級 ) at least two It is obtained ( 獲得 ) from standard trie by compressing chains of “redundant” ( 重複 ) nodes

7 © 2004 Goodrich, Tamassia Tries7 Compressed Tries - Compact Representation Compact representation of a compressed trie for an array of strings: Stores at the nodes ranges ( 範圍 ) of indices ( 索引 ) instead of ( 而非 ) substrings Uses O(s) space, where s is the number of strings in the array Serves ( 當作 ) as an auxiliary ( 輔助 ) index structure

8 © 2004 Goodrich, Tamassia Tries8 Suffix Tries The suffix trie of a string X is the compressed trie of all the suffixes ( 接尾 ) of X

9 © 2004 Goodrich, Tamassia Tries9 Suffix Tries - Compact Representation Compact representation of the suffix trie for a string X of size n from an alphabet of size d Uses O(n) space Supports arbitrary pattern matching queries in X in O(dm) time, where m is the size of the pattern Can be constructed in O(n) time


Download ppt "© 2004 Goodrich, Tamassia Tries1 Chapter 7 Tries Topics Basics Standard tries Compressed ( 壓縮 ) tries Suffix ( 尾字 ) tries."

Similar presentations


Ads by Google