Ashwin-op / B_and_Bplus_Tree

Implementation of B and B+ Trees in python
MIT License
30 stars 9 forks source link

hi,i download your code and debug in my laptop,but i face IndexError: list index out of range #2

Open yuantianwen opened 2 years ago

yuantianwen commented 2 years ago

`def main(): B = BTree(2) ------ i changed

# Insert
customNo = 20   ------  i changed
for i in range(1,customNo+1):
    B.insert((i, randint(i, 5 * i)))
B.printTree(B.root)
print()

`

when i run,i get the following error: `E:\workspace\PycharmProjects\B_and_Bplus_Tree\venv\Scripts\python.exe E:/workspace/PycharmProjects/B_and_Bplus_Tree/B-Tree.py Level 0 --> 1: (8, 31) Level 1 --> 1: (4, 10) Level 2 --> 1: (2, 6) Level 3 --> 1: (1, 4) Level 1 --> 1: (12, 30) Level 2 --> 1: (10, 19) Level 3 --> 1: (9, 22) Level 2 --> 3: (14, 32) (16, 42) (18, 25) Level 3 --> 1: (13, 14) Level 3 --> 1: (15, 27) Level 3 --> 1: (17, 58) Level 3 --> 2: (19, 76) (20, 71)

Key 12 deleted! Traceback (most recent call last): File "E:/workspace/PycharmProjects/B_and_Bplus_Tree/B-Tree.py", line 313, in main() File "E:/workspace/PycharmProjects/B_and_Bplus_Tree/B-Tree.py", line 298, in main B.delete(B.root, (toDelete,)) File "E:/workspace/PycharmProjects/B_and_Bplus_Tree/B-Tree.py", line 156, in delete self.delete(x.children[i], k) IndexError: list index out of range

Process finished with exit code 1 `

Ashwin-op commented 2 years ago

There might have been some edge cases that I overlooked

Ashwin-op commented 5 months ago

@yuantianwen I fixed some stuff in B-Tree, do test it out and let me know if you still get any errors