Professional Documents
Culture Documents
Example
Start with an empty digital search tree and insert a pair whose key is 0110.
0110
0010
Example
Now, insert a pair whose key is 1001.
0110 0110
0010
0010
1001
Example
Now, insert a pair whose key is 1011.
0110 0010 0110
0010
1001
1001
1011
Example
Now, insert a pair whose key is 0000.
0110 0010 0110
0010
1001 0000
1001
1011
1011
Search/Insert/Delete
0110
0010
1001
0000
1011
Complexity of each operation is O(#bits in a key). #key comparisons = O(height). Expensive when keys are very long.
Binary Trie
Information Retrieval. At most one key comparison per operation. Fixed length keys.
Branch nodes. Left and right child pointers. No data field(s). Element nodes. No child pointers. Data field to hold dictionary pair.
Example
0 0 0 0001 1 0011 0 1 0 1
1100
0
1000
1
1001
Example
0 null 1 10 0 1000 1 00100 001100 101 11111
0
00 0 0000 001 01100
0111
1100
0
1000
1
1001
Insert 0111.
Zero compares.
0111
1100
0
1000
1
1001
Insert 1101.
0111
0 1
1001 0
0
1000
Insert 1101.
0111
0 1
1001 0 1100 1 1101
0
1000
Insert 1101.
One compare.
0111
0 1
1001 0 1100 1 1101
0
1000
Delete 0111.
0 1
1001 0 1100 1 1101
0
1000
Delete 0111.
One compare.
0 1
1001 0 1100 1 1101
0
1000
Delete 1100.
0 1
1001 1 1101
0
1000
Delete 1100.
0 1
1001
0
1000
Delete 1100.
0
1000
1
1001
Delete 1100.
1101
0
1000
1
1001
Delete 1100.
One compare.
S
a b
B
c
J(S,B)
J(b,c)
Complexity = O(height).