Redistribute keys from right sibling to child
(self, parent: "BranchNode", child_index: int)
| 339 | parent.keys[child_index - 1] = new_separator |
| 340 | |
| 341 | def _redistribute_from_right(self, parent: "BranchNode", child_index: int) -> None: |
| 342 | """Redistribute keys from right sibling to child""" |
| 343 | child = parent.children[child_index] |
| 344 | right_sibling = parent.children[child_index + 1] |
| 345 | |
| 346 | if child.is_leaf(): |
| 347 | # Leaf redistribution |
| 348 | child.borrow_from_right(right_sibling) |
| 349 | # Update separator key in parent |
| 350 | parent.keys[child_index] = right_sibling.keys[0] |
| 351 | else: |
| 352 | # Branch redistribution |
| 353 | separator_key = parent.keys[child_index] |
| 354 | new_separator = child.borrow_from_right(right_sibling, separator_key) |
| 355 | parent.keys[child_index] = new_separator |
| 356 | |
| 357 | def _merge_with_sibling(self, parent: "BranchNode", child_index: int) -> None: |
| 358 | """Merge an underfull child with one of its siblings""" |
no test coverage detected