Data Structures/B+ Tree
treebalancedmultiway
Press play to start
1int bplus_search(BNode* root, int val) {
2 BNode* curr = root;
3 while (!curr->is_leaf) {
4 int i = 0;
5 while (i < curr->n && val >= curr->keys[i]) i++;
6 curr = curr->children[i];
7 }
8 for (int i = 0; i < curr->n; i++)
9 if (curr->keys[i] == val) return 1;
10 return 0;
11}
Step 1/0

Practice

LeetCode·#938 Range Sum of BSTEasy
OperationBestAverageWorst
searchO(log n)O(log n)O(log n)
insertO(log n)O(log n)O(log n)
scanO(log n + k)O(log n + k)O(log n + k)
SpaceO(n)