Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yuantianwen opened this issue Oct 5, 2021 · 2 comments

Comments

@yuantianwen
Copy link

`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
Copy link
Owner

Ashwin-op commented Oct 12, 2021

There might have been some edge cases that I overlooked

@Ashwin-op
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants