Esempio n. 1
0
def random_indices_tree (length):
    t = avl.newavl()
    # build a 'list' of indices
    for num in range(length):
        t.insert(num)
    t2 = avl.newavl()
    for x in range(length):
        i = random.choice(t)
        t2.insert((x,i))
        t.remove(i)
    # return the tree as a list
    return map (lambda x: x[1], t2)
Esempio n. 2
0
def test(n):
    tree = avl.newavl()
    print 'generating random numbers...'
    t = timer(); nums = generate_test_numbers (n); t.end()
    fill_up(tree,nums)
    slice_test(tree)
    empty(tree)