print(f"Branching factor: {B}") insertcounter = 0 while len(lst) != NUM: new_v = randrange(100) if new_v not in lst: lst.append(new_v) insertcounter += 1 print(f"Inserted {insertcounter} items") bt = Btree(B) for ind, el in enumerate(lst): bt.insert(el, ind) delcounter = 0 listLength = len(lst) for i in range(len(lst)): delvalue = random.choice(lst) lst.remove(delvalue) bt.delete(delvalue) # if counter >= listLength/2: # break delcounter += 1 print(f"Deleted {delcounter} items") bt.plot()
lines = dataBack.readlines() lst = [] for i in lines: lst.append(int(i)) dataBack.close() bt = Btree(B) for ind, el in enumerate(lst): #print(el, ind) bt.insert(el, ind) bt.plot("Pre") i = 0 for q in range(0, 5): n = randrange(NUM) if bt.delete(n) == True: i = i + 1 bt.plot("/Step " + str(i)) print("Step " + str(i)) sleep(0.2) print("--------") #else: # sleep(0.02) #bt.delete(2) #bt.setColumn(1, "Students", 14)