CPSC-310 Database Systems Professor Jianer Chen Room 315C HRBB Lecture #18
B+Trees Support fast search Support range search Support dynamic changes Could be either dense or sparse * dense: pointers to all records * sparse: one pointer per block Notes #7
B+Trees A B+tree node of order n How big is n? where ph are pointers (disk addresses) and kh are search-keys (values of the attributes in the index) How big is n? Basically we want each B+tree node to fit in a disk block so that a B+tree node can be read/written by a single disk I/O. Typically, n ~ 100-200. p1 k1 p2 k2 …… pn kn pn+1 Notes #7
B+Tree Example order n = 3 root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Sample non-leaf order n = 3 57 81 95 To keys k < 57 To keys 57 k<81 To keys 81 k<95 To keys k 95 Notes #7
Sample leaf node order n = 3 From non-leaf node To next leaf in sequence 57 81 95 To record with key 57 To record with key 81 To record with key 95 Notes #7
A B+Tree of order n Each node has: n keys and n+1 pointers These are fixed To keep the nodes not too empty, also for the operations to be applied efficiently: * Non-leaf: at least (n+1)/2 pointers (to children) * Leaf: at least (n+1)/2 pointers to data (plus a “sequence pointer” to the next leaf) Basically: use at least one half of the pointers Notes #7
Example (B+ tree of order n=3) Full node Min. node 120 150 180 30 Non-leaf 3 5 11 30 35 Leaf Notes #7
B+tree rules Notes #7
B+tree rules Rule 1. All leaves are at same lowest level (balanced tree) Notes #7
B+tree rules Rule 1. All leaves are at same lowest level (balanced tree) Rule 2. Pointers in leaves point to records except for “sequence pointer” Notes #7
B+tree rules Rule 1. All leaves are at same lowest level (balanced tree) Rule 2. Pointers in leaves point to records except for “sequence pointer” Rule 3. Number of keys/pointers in nodes: Max. # pointers Max. # keys Min. # keys Non-leaf n+1 n (n+1)/2 (n+1)/2 1 Leaf (n+1)/2 + 1 (n+1)/2 Root 2 1 Notes #7
B+tree rules Rule 1. All leaves are at same lowest level (balanced tree) Rule 2. Pointers in leaves point to records except for “sequence pointer” Rule 3. Number of keys/pointers in nodes: Max. # pointers Max. # keys Min. # keys Non-leaf n+1 n (n+1)/2 (n+1)/2 1 Leaf (n+1)/2 + 1 (n+1)/2 Root 2 1 could be 1 Notes #7
Search in a B+tree Notes #7
Search in a B+tree Start from the root Search in a leaf block May not have to go to the data file Search(ptr, k); \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Notes #7
Search in a B+tree Start from the root Search in a leaf block May not have to go to the data file Search(ptr, k); \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Notes #7
Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 A tree node \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Notes #7
Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 A tree node \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 A tree node \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Search(*prt, 130) root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 A tree node \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Search(*prt, 130) root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 A tree node \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Search(*prt, 130) root 100 100 130 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 A tree node \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Search(*prt, 130) root 100 100 130 30 120 150 180 120 130 <150 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 A tree node \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Search(*prt, 130) root 100 100 130 30 120 150 180 120 130 <150 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 130 =130 return Notes #7
Range Search in B+tree To research all records whose key values are between k1 and k2: Notes #7
Range Search in B+tree To research all records whose key values are between k1 and k2: Range-Search(ptr, k1, k2) Notes #7
Range Search in B+tree To research all records whose key values are between k1 and k2: Range-Search(ptr, k1, k2) Call Search(ptr, k1); Notes #7
Range Search in B+tree To research all records whose key values are between k1 and k2: Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 30 50 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 30 50 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 35 < 50 Not Return Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 30 50 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 35 < 50 Not Return Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 30 50 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 35 < 50 100 125 110 125 Not Return return return 101 125 return Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 30 50 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 35 < 50 100 125 110 125 Not Return return return 101 125 return Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 30 50 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 35 < 50 100 125 110 125 Not Return return return 101 125 120 125 return return Notes #7
Range Search in B+tree Search(ptr, k); p1 k1 p2 k2 …… pn kn pn+1 \\ search a record of key value k in the subtree rooted at ptr \\ assume the B+tree is a dense index of order n Case 1. ptr is a leaf \\ pn+1 is the sequence pointer IF (k = ki) for a key ki in *ptr THEN return(pi); ELSE return(Null); Case 2. ptr is not a leaf find a key ki in *ptr such that ki-1 ≤ k < ki; return(Search(pi, k)); Range Search in B+tree p1 k1 p2 k2 …… pn kn pn+1 A tree node Range-Search(ptr, k1, k2) Call Search(ptr, k1); Follow the sequence pointers until the search key value is larger than k2. Range-Search(*prt, 50, 125) Search(*prt, 50) root 100 50 < 100 30 120 150 180 30 50 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200 35 < 50 100 125 110 125 135 > 125 Not Return return return STOP 101 125 120 125 return return Notes #7
Insert into B+tree Notes #7
Insert into B+tree Basic idea: Notes #7
Insert into B+tree Basic idea: Find the leaf L where the record r should be inserted; Notes #7
Insert into B+tree Basic idea: Find the leaf L where the record r should be inserted; If L has further room, then insert r into L, and return; Notes #7
Insert into B+tree Basic idea: Find the leaf L where the record r should be inserted; If L has further room, then insert r into L, and return; If L is full, spilt L plus r into two leaves (each is about half full): this causes an additional child for the parent P of L, thus we need to add a child to P; Notes #7
Insert into B+tree Basic idea: Find the leaf L where the record r should be inserted; If L has further room, then insert r into L, and return; If L is full, spilt L plus r into two leaves (each is about half full): this causes an additional child for the parent P of L, thus we need to add a child to P; If P is already full, then we have to split P and add an additional child to P’s parent … (recursively) Notes #7
Insert into B+tree Simple case (space available for new child) Leaf overflow Non-leaf overflow New root Notes #7
Insert into B+tree Simple case (space available for new child) Leaf overflow Non-leaf overflow New root Notes #7
I. Simple case: Insert key 32 order n=3 100 30 40 3 5 11 30 31 Notes #7
I. Simple case: Insert key 32 order n=3 Insert(prt, 32) 100 30 40 3 5 11 30 31 Notes #7
I. Simple case: Insert key 32 order n=3 Insert(prt, 32) 100 32 < 100 30 40 30 32 <40 3 5 11 30 31 Notes #7
I. Simple case: Insert key 32 order n=3 Insert(prt, 32) 100 32 < 100 30 40 30 32 <40 3 5 11 30 31 room for 32 Notes #7
I. Simple case: Insert key 32 order n=3 Insert(prt, 32) 100 32 < 100 30 40 30 32 <40 3 5 11 30 31 32 Notes #7
Insert into B+tree Simple case (space available for new child) Leaf overflow Non-leaf overflow New root Idea: when there is no space for a new child (all pointers are in use), split the node into two nodes, with both at least half full. Notes #7
Complication: node overflow Notes #7
Complication: Leaf overflow Notes #7
Complication: Leaf overflow p k p’ p1 k1 … p k p k … … pn kn p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 pn+1 kn+1 Notes #7
Complication: Leaf overflow p k k p’ p1 k1 … p k --- p** p k … pn kn pn+1 kn+1 --- p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 p k p’ p1 k1 … p k p k … … pn kn p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 pn+1 kn+1 Notes #7
Complication: Leaf overflow p k k p’ p1 k1 … p k --- p** p k … pn kn pn+1 kn+1 --- p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 p k p’ p1 k1 … p k p k … … pn kn p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 pn+1 kn+1 Notes #7
Complication: Leaf overflow p k k p’ q p1 k1 … p k --- p** p k … pn kn pn+1 kn+1 --- p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 p k p’ p1 k1 … p k p k … … pn kn p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 pn+1 kn+1 Notes #7
Complication: Leaf overflow p k k p’ ? q What is the key here? p1 k1 … p k --- p** p k … pn kn pn+1 kn+1 --- p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 p k p’ p1 k1 … p k p k … … pn kn p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 pn+1 kn+1 Notes #7
Complication: Leaf overflow p k k p’ ? q What is the key here? p1 k1 … p k --- p** p k … pn kn pn+1 kn+1 --- p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 p k p’ p1 k1 … p k p k … … pn kn p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 pn+1 kn+1 Notes #7
Complication: Leaf overflow p k k p’ q 𝑛+1 /2 +1 p1 k1 … p k --- p** p k … pn kn pn+1 kn+1 --- p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 p k p’ p1 k1 … p k p k … … pn kn p* 𝑛+1 /2 𝑛+1 /2 𝑛+1 /2 +1 𝑛+1 /2 +1 pn+1 kn+1 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 30 3 5 11 30 31 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 30 7 3 5 11 30 31 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 30 3 5 7 11 30 31 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 30 3 5 7 11 30 31 3 5 11 7 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 30 3 5 7 11 30 31 3 5 11 7 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 30 3 5 7 11 30 31 3 5 11 7 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 30 3 5 7 11 30 31 3 5 11 7 Notes #7
Leaf overflow: Insert key 7 (order n = 3) 100 7 30 3 5 7 11 30 31 3 5 11 7 Notes #7
Complication: nonleaf overflow Notes #7
Complication: nonleaf overflow p k’ p’ kn+1 pn+2 p1 k1 … p k p k p k … pn kn pn+1 (𝑛+1)/2 (𝑛+1)/2 -1 (𝑛+1)/2 +1 (𝑛+1)/2 +1 Notes #7
Complication: nonleaf overflow p k’ p’ k q (𝑛+1)/2 p1 k1 p2 k2 … p k p p k … pn kn pn+1 kn+1 pn+2 (𝑛+1)/2 -1 (𝑛+1)/2 -1 (𝑛+1)/2 (𝑛+1)/2 +1 (𝑛+1)/2 +1 p k’ p’ kn+1 pn+2 p1 k1 … p k p k p k … pn kn pn+1 (𝑛+1)/2 (𝑛+1)/2 -1 (𝑛+1)/2 +1 (𝑛+1)/2 +1 Notes #7
Complication: nonleaf overflow p k’ p’ k q (𝑛+1)/2 p1 k1 p2 k2 … p k p p k … pn kn pn+1 kn+1 pn+2 (𝑛+1)/2 -1 (𝑛+1)/2 -1 (𝑛+1)/2 (𝑛+1)/2 +1 (𝑛+1)/2 +1 p k’ p’ kn+1 pn+2 p1 k1 … p k p k p k … pn kn pn+1 (𝑛+1)/2 (𝑛+1)/2 -1 (𝑛+1)/2 +1 (𝑛+1)/2 +1 Notes #7
Complication: nonleaf overflow p k’ p’ k q (𝑛+1)/2 p1 k1 p2 k2 … p k p p k … pn kn pn+1 kn+1 pn+2 (𝑛+1)/2 -1 (𝑛+1)/2 -1 (𝑛+1)/2 (𝑛+1)/2 +1 (𝑛+1)/2 +1 p k’ p’ kn+1 pn+2 p1 k1 … p k p k p k … pn kn pn+1 (𝑛+1)/2 (𝑛+1)/2 -1 (𝑛+1)/2 +1 (𝑛+1)/2 +1 Notes #7
Complication: nonleaf overflow p k’ p’ k ? q (𝑛+1)/2 What is the key here? p1 k1 p2 k2 … p k p p k … pn kn pn+1 kn+1 pn+2 (𝑛+1)/2 -1 (𝑛+1)/2 -1 (𝑛+1)/2 (𝑛+1)/2 +1 (𝑛+1)/2 +1 p k’ p’ kn+1 pn+2 p1 k1 … p k p k p k … pn kn pn+1 (𝑛+1)/2 (𝑛+1)/2 -1 (𝑛+1)/2 +1 (𝑛+1)/2 +1 Notes #7
Complication: nonleaf overflow p k’ p’ k ? q (𝑛+1)/2 What is the key here? p1 k1 p2 k2 … p k p p k … pn kn pn+1 kn+1 pn+2 (𝑛+1)/2 -1 (𝑛+1)/2 -1 (𝑛+1)/2 (𝑛+1)/2 +1 (𝑛+1)/2 +1 p k’ p’ not used kn+1 pn+2 p1 k1 … p k p k p k … pn kn pn+1 (𝑛+1)/2 (𝑛+1)/2 -1 (𝑛+1)/2 +1 (𝑛+1)/2 +1 Notes #7
Complication: nonleaf overflow p k’ p’ k k q (𝑛+1)/2 (𝑛+1)/2 p1 k1 p2 k2 … p k p p k … pn kn pn+1 kn+1 pn+2 (𝑛+1)/2 -1 (𝑛+1)/2 -1 (𝑛+1)/2 (𝑛+1)/2 +1 (𝑛+1)/2 +1 p k’ p’ kn+1 pn+2 p1 k1 … p k p k p k … pn kn pn+1 (𝑛+1)/2 (𝑛+1)/2 -1 (𝑛+1)/2 +1 (𝑛+1)/2 +1 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 100 120 150 180 160 150 156 179 180 210 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 100 120 150 180 150 156 160 179 180 210 150 156 179 160 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 100 120 150 180 150 156 160 179 180 210 150 156 179 160 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 100 120 150 180 160 150 156 160 179 180 210 150 156 179 160 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 100 120 150 180 no room! 160 150 156 160 179 180 210 150 156 179 160 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 120 150 180 160 100 120 150 180 160 150 156 160 179 180 210 150 156 179 160 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 120 150 180 160 100 120 150 180 160 150 156 160 179 180 210 150 156 179 160 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 120 150 180 160 100 160 120 150 180 160 150 156 160 179 180 210 150 156 179 160 Notes #7
Nonleaf overflow: Insert key 160 (order n = 3) 100 160 120 150 180 150 156 160 179 180 210 Notes #7