void splitChild(BTreeNode* parent, int i, BTreeNode* child) { BTreeNode* newNode = createNode(child->leaf); newNode->n = MIN - 1; for (int j = 0; j < MIN - 1; j++) { newNode->keys[j] = child->keys[j + MIN]; } if (!child->leaf) { for (int j = 0; j < MIN; j++) { newNode->children[j] = child->children[j + MIN]; } } child->n = MIN - 1; for (int j = parent->n; j >= i + 1; j--) { parent->children[j + 1] = parent->children[j]; } parent->children[i + 1] = newNode; for (int j = parent->n - 1; j >= i; j--) { parent->keys[j + 1] = parent->keys[j]; } parent->keys[i] = child->keys[MIN - 1]; parent->n++; }