B-trees - Chapter 10 Flashcards
In a blank each node has one key and up to two children.
binary tree
A blank with order K is a tree where nodes can have up to K-1 keys and up to K children.
B-tree
The blank is the maximum number of children a node can have. Ex: In a B-tree with order 4, a node can have 1, 2, or 3 keys, and up to 4 children.
order
B-trees have the following 5 properties:
All keys in a B-tree must be distinct.
All leaf nodes must be at the same level.
An internal node with N keys must have N+1 children.
Keys in a node are stored in sorted order from smallest to largest.
Each key in a B-tree internal node has one left subtree and one right subtree. All left subtree keys are < that key, and all right subtree keys are > that key.
As the order of a B-trees blank, the maximum number of keys and children per node increases. An internal node must have one more child than keys. Each child of an internal node can have a different number of keys than the parent internal node. Ex: An internal node in an order 5 B-tree could have 1 child with 1 key, 2 children with 3 keys, and 2 children with 4 keys.
increases
A is an order 4 B-tree. Therefore, a 2-3-4 tree node contains 1, 2 or 3 keys. A leaf node in a 2-3-4 tree has no children.
2-3-4 tree
The keys and children in a 2-3-4 tree node are commonly referred to by blank. So keys are called key 0, key 1, and key 2, and children are called child 0, child 1, child 2, and child 3. If a node has one key, then keys 1 and 2 and children 2 and 3 are not used.
index.
If a node contains two keys, then key 2 and child 3 are not used. A 2-3-4 tree node containing three keys is said to be blank.
full
A node with one key is called a blank. A node with two keys is called a blank. A node with three keys is called a blank
2-node.
3-node
4-node.
Given a key, a blank algorithm returns the first node found matching that key, or returns null if a matching node is not found. Searching a 2-3-4 tree is a recursive process that starts with the root node. If the search key equals any of the keys in the node, then the node is returned. Otherwise, a recursive call is made on the appropriate child node. Which child node is used depends on the value of the search key in comparison to the node’s keys. The table below shows conditions, which are checked in order, and the corresponding child node
search
key < node’s A key Child node to search
left
node has only 1 key or key < node’s B key Child node to search
middle1
node has only 2 keys or key < node’s C key Child node to search
middle2
not - key < node’s A key or node has only 1 key or key < node’s B key or node has only 2 keys or key < node’s C key Child node to search
right
Given a new key, a 2-3-4 tree blank inserts the new key in the proper location such that all 2-3-4 tree properties are preserved. New keys are always inserted into leaf nodes in a 2-3-4 tree. Insertion returns the leaf node where the key was inserted, or null if the key was already in the tree.
insert operation
An important operation during insertion is the blank, which is done on every full node encountered during insertion traversal. The split operation moves the middle key from a child node into the child’s parent node. The first and last keys in the child node are moved into two separate nodes. The split operation returns the parent node that received the middle key from the child.
split operation
Splitting an internal node allocates blank, each with a single key, and the middle key from the split node moves up into the parent node. Splitting the root node allocates blank, each with a single key, and the root of the tree becomes a new node with a single key.
2 new nodes
3 new nodes
During a split operation, any blank may need to gain a key from a split child node. This key may have children on either side.
non-full internal node