B-trees, multiway trees, B+ trees
B+ tree properties
>Data stored at leaves >Non-leaf nodes store M-1 keys to guide the search, key i represents the smallest key in subtree i+1 >root is either a leaf or has between 2 and M children >All non-leaf nodes except the root have between ceil(M/2) and M children >All leaves except the root are the same depth and have between ceil(L/2) and L data entries; L is the number of data record that can be stored in each leaf
Bit-level try
Binary tree which differs from a binary search tree so that the decision to go left or right depends on current bit. Lose advantage of multiway tree (reducing depth), finds longest match, speeds up failed finds
Use of B-tree
Databases and file systems
B tree of order M
Every node has at most M children A non-leaf node with k children contains k-1 keys The root has at least two children if it is not a leaf Every non-leaf node has a minimum of ceil(m/2) children All leaves are on the same level
B tree advantages
Faster when you do a seek (look for a specific data by key), B+ tree faster when doing a full scan
Adding
If full, split, the medium value gets 'promoted', split until it works. Each parent of a leaf stores the number that the leaf begins with.
Trie - root is associated with
the empty string
Multi-way tree
tree that can have more than two children, of order m - max m children; a binaary tree is a multi-way tree with m=2
Suffix trie
trie of all suffixes of a string, important for string-based algorithms, find query string Q in a text T
Disadvantages of tries
waste memory
Properties of m-ary trees
Maximum number of leaves for height h is k^h Tree containing only a root 0 is zero
B-tree time complexity
O(logn)
How much memory for suffix tries when using pointers to original text
O(n) where n is the length of the text, there is a linear time O(n) algorithm to construct the trie
Uses of b+-tree
Retrieval in a block-oriented storage context - file system; used fro indexing database tables.
B+ tree advanatages
The leaf nodes of B+ trees are linked, so doing a full scan of all objects in a tree requires just on linear pass through all the leaf node; a B tree would require a traversal in every level of the tree B+tree is less deep than a B tree
Tries (digital tree, radix tree, prefix tree)
digital tree, multiway tree for storing words. The position in the tree defines the key with which it is associated.
Tries are a way of
implementing sets
B-tree time complexity for search, insert, delete, both theta and O
log n
Access time of a multi way tree
log2(n)/log2(M)
Trie - all words end with
$ (words == leaves)
B+ Tree
B-tree with each node only containing keys (not key-value pairs) to which an additional level is added at the bottom with linked leaves
Tries compactify edges in the tree to remove
Internal one way branching in the internal nodes and external one way branching in the leaves
When to use a suddix trie
When you do multiple searches, dynamic programming, bioinformatics
Tries are (quicker/slower) than
binary trees and hash tables
To match a query string,
construct suffix tree, then simply look up query
Tries provide
quick insertion, deletion, find
How to improve disk access?
replace disk memory with a solid-state drive.
B-tree
self-balancing data structure, maintains sorted data
Tries are good for
spell checkers, completion algorithms, longest prefix matching, hyphenation