Skip to content

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

@yuantianwen

Description

@yuantianwen

`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
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions