lec18 - with average length Space: one character for each...

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

View Full Document Right Arrow Icon
Outline Tries for words Tries for bitstrings Compressed Tries Time/Space Analysis Lecture 18, Tries p. 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
Time/Space Analysis Worst case query time: find the longest string Average case query time: find the string
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9
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: inecient 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

This note was uploaded on 07/17/2010 for the course CS 240 taught by Professor Ortiz during the Spring '09 term at Waterloo.

Page1 / 9

lec18 - with average length Space: one character for each...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online