Multiway trie properties
-
The structure of a multiway trie depends only on the keys in it, not on the order in which they were inserted
-
Multiway tries have a strong key ordering property: At a node X, all keys in X’s leftmost subtree are smaller than keys in X’s next-to-leftmost subtree, etc. (according to lexicographic ordering)
-
So, a preorder traversal of a multiway trie visits keys in sorted order
-
Also, after following a sequence of digits to get to a node X, all keys in the trie that have that sequence as prefix are in the subtree rooted at X
-
Suppose there are r bits per digit (so radix R = 2
r
), and keys contain at most B bits. Then:
-
The worst case height of a R-ary trie containing N keys is B/r
-
Compare: worst case height in a regular BST containing N keys is N, which with B-bit keys can be as much as 2
B
-
When N is large and B is comparable to log
R
N, DST’s give worst-case time cost guarantees better than balanced BST’s, and are much easier to implement
-
However there is a space cost disadvantage of multiway trees: Each node must store R child pointers, and for a typical tree many of these will be null
-
This problem can be addressed with ternary tries
CONTENTS PREVIOUS NEXT