{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec18

# lec18 - with average length • Space one character for...

This preview shows pages 1–9. Sign up to view the full content.

Outline Tries for words Tries for bitstrings Compressed Tries Time/Space Analysis Lecture 18, Tries p. 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Data Structures for Tries Each node stores an array of children Each child represents one possible charac- ter Keys are stored in leaves Lecture 18, Tries p. 2
A example of a trie Keys: be, bear, bell, so, soup, soul bear 1st char 2nd char b s e o a l \$ u \$ l p 3rd char 2nd char 3rd char so 4th char soup soul be bell Lecture 18, Tries p. 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Operations on Tries Idea: similar to BST, but the branch is deter- mined by a character Search Insertion Deletion An Example: operations on a trie for words (from the previous example) Search(”be”) Search(”soup”) Insert(”belt”) Lecture 18, Tries p. 4
Example 2: a trie for bitstrings 1 2nd bit 2nd bit 1st bit 001 3rd bit 3rd bit 010 011101 11010 1111 0 1 0 1 1 0 1 0 Lecture 18, Tries p. 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Time/Space Analysis Worst case query time: find the longest string Average case query time:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: with average length • Space: one character for each internal nodes; how many internal nodes in total? O ( M ( | Σ | + 1)), where M is the number of internal nodes. How is M related to n and the length of the strings? Lecture 18, Tries p. 6 Compressed Tries • Problem: ineﬃcient space usage, many in-termediate nodes are unnecessary. • Idea: compress unnecessary internal nodes – Idea 1: store a sub-string on one path – Idea 2: only store characters where keys are separated into more than one sub trees. Lecture 18, Tries p. 7 An example Idea 1: so be so a l \$ u \$ l p bear bell be soul soup Idea 2: Lecture 18, Tries p. 8 bear a l \$ u \$ l p 1st char 3rd char 3rd char 4th char s b so soup soul be bell Lecture 18, Tries p. 9...
View Full Document

{[ snackBarMessage ]}

### Page1 / 9

lec18 - with average length • Space one character for...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online