prev

next

of 24

View

28Category

## Documents

Embed Size (px)

DESCRIPTION

0. 1. 2. 3. 4. 5. 6. 7. 8. 9. Higher Order Tries. Key = Social Security Number. 441-12-1135 9 decimal digits. 10 -way trie (order 10 trie). Height

- Higher Order TriesKey = Social Security Number.441-12-11359 decimal digits.10-way trie (order 10 trie).Height
- Social Security Trie10-way trieHeight
Social Security AVL & Red-Black

Red-black treeHeight

Compressed Social Security Triechar# = character/digit used for branching.Equivalent to bit# feld of compressed binary trie.#ptr = # of nonnull pointers in the node.

InsertInsert 012345678.012345678Insert 015234567.Null pointer fields not shown.

InsertInsert 015231671.

InsertInsert 079864231.

InsertInsert 012345618.

InsertInsert 011917352.17

Insert1782501234567801523456714601523167120798642311701234561813011917352

DeleteDelete 011917352.

Delete178250123456780152345671460152316712079864231170123456183Delete 012345678.

Delete17250152345671460152316712079864231012345618Delete 015231671.3

Delete172501523456720798642310123456183

Variable Length KeysInsert 0123.Problem arises only when one key is a (proper) prefix of another.

Variable Length KeysInsert 0123.Add a special end of key character (#) to each key to eliminate this problem.

Variable Length KeysEnd of key character (#) not shown.

Tries With Edge InformationAdd a new field (element) to each branch node.New field points to any one of the element nodes in the subtree. Use this pointer on way down to figure out skipped-over characters.

Exampleelement field shown in blue.

Etc.Expected height of an order m trie is ~logmn.Limit height to h (say 6). Level h branch nodes point to buckets that employ some other search structure for all keys in subtrie.

Etc.

Switch from trie scheme to simple array when number of pairs in subtrie becomes

Multibit TriesVariant of binary trie in which the number of bits (stride) used for branching may vary from node to node.Proposed for Internet router applications.Variable length prefixes.Longest prefix match.Limit height by choosing node strides.Root stride = 32 => height = 1.Strides of 16, 8, and 8 for levels 1, 2, and 3 => only 3 levels.

Multibit Trie Example

Multibit TriesNode whose stride is s uses s bits for branching.Node has 2s children and 2s element/prefix fields.Prefixes that end at a node are stored in that node.Short prefixes are expanded to length represented by node.When root stride is 3, prefixes whose length is < 3 are expanded to length 3.P = 00* expands to P0 = 000* and P1 = 001*.If Q = 000* already exists P0 is eliminated because Q represents a longer match for any destination.

10-way trie => at most 10 cache misses for a search! Up to 9 branch levels and 1 element level.100-way => at most 6 misses.With 1million entries, height of red-black tree is at most 40.Fall off root during search for insert key. Find any key in subtree you fall off of and find first character where this key and insert key differ. In the example, this is character/digit 2. Can back up at most one level.Can back up at most one level.Can back up at most one level.Element field also useful for insert.Length 1 prefix is stored in root. How about length 2 and begins with 0? Expand to length 3. Fixed and variable stride tries. Find strides so as to minimize space requirement.