A B+tree Implementation in C
- The only hardcoded parameter is
p
that is the order of the tree (i.e. maximum number of pointers on a node)- NOTE: node can have up to
p+1
pointers to accommodate the overflow which will then be handled by node splits - The actual number of pointers :=
q
whereq
∈ [2,p
] or ([2,p+1
] illegally) fork
≥ 1 (k
:= number of actual keys) k
will always be equal toq - 1
- NOTE: node can have up to
- Level starts from 1 (i.e. root sits at level 1)
- For all search field values
X
in the subtree pointed at byP_i
, we haveK_{i−1} < X ≤ K_i
for 1 <i
<q
;X ≤ K_i
fori = 1
; andK_{i−1} < X
fori = q
- Keys == search field values; values/data == data file record
- a good visualization tool: https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html
- NOTE: this visualization defines as such:
K_{i−1} <= X < K_i
for 1 <i
<q
;X < K_i
fori = 1
; andK_{i−1} <= X
fori = q
, which differs from this design
- NOTE: this visualization defines as such:
all you have to do is:
for (int i = 0; i < total_number_of_keys_you_want_to_insert; i++)
{
insert(keys_arr[i], values_arr[i]);
}
in main.c
- single linked-list on the leaf level (if there is a need to implement it, which I don't find one yet)
- deletion?