def populate(n): myList = [] myBST = BST() while len(myList) != n: randNum = (random.randrange(0, n + 1)) myList.append(randNum) myBST.append(randNum) return (myList, myBST)
def populate(n): randomList = [] bstList = BST() for i in range(0, n): randomList.append(random.randint(0, n)) bstList.append(random.randint(0, n)) return (randomList, bstList)
def populate(n): randomList = [] bst = BST() for i in range(0, n): randomInt = random.randint(0, n) randomList.append(randomInt) bst.append(randomInt) return [randomList, bst]
def populate(n): if (isinstance(n, int)): if (n < 0): raise Exception('n has to be a positive integer') else: newList = [] newBST = BST() for i in range(0, n): randInt = random.randint(0, n) newList.append(randInt) newBST.append(randInt) return (newList, newBST) else: raise Exception('n has to be an integer')
def populate(n): main = random.sample(range(1, 10000), n) tree = BST() for i in main: tree.append(i) return main, tree