Ch 6: Balanced Trees I Flashcards
what is a B-tree?
a tree with order K where nodes can have up to K-1 trees and up to K children
what is order?
the maximum number of children a node can have
what are the 5 properties of B-trees?
- 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 subtrees are < that key, and all right subtree keys are > that key
what makes a node full?
a 2-3-4 tree node that has exactly 3 keys
what are the key labels of a 2-3-4 tree?
A,B,C
what are the child node labels of a 2-3-4 tree?
left, middle 1, middle 2, right
how many children can a node with K keys have?
K+1
explain the 2-3-4 tree search 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.
explain what the insert operation does
new keys are inserted into leaf nodes in a 2-3-4 tree, returns the leaf node where the key was inserted or null if the key was already in the tree
what is the split operation?
an operation that is executed on every full node encountered during insertion traversal
explain the split operation
- moves middle from a child node into the child’s parent node
- the first and last keys in the child node are moved into separate nodes
- returns the parent node that received the middle key from the child
how many new nodes are allocated during split?
- 2 when splitting an internal node
- 3 when splitting root
what is the preemptive split?
an insertion scheme that always splits any full node encountered during an insertion traversal
what does the preemptive split ensure?
ensures that any time a full node is split, the parent node has room to accommodate the middle value from the child
what is rotation?
a rearrangement of keys between 3 nodes that maintains all 2-3-4 tree properties in the process