Closed 3q-coder closed 5 years ago
You are correct, thank you for spotting that :D
For example, MAX_LEAF_COUNT = 4
You try to insert 4 times, incrementing self._cur
which starts at zero, which represents the index of the next leaf which will be inserted.
_cur=0
_cur=1
_cur=2
_cur=3
<--- it will fail here, because _cur == 3
So last item will fail to insert.
It looks like it is necessary to replace
MAX_LEAF_COUNT - 1
withMAX_LEAF_COUNT
. Because it is impossible to insert the last leaf in the current implementation.