Ejemplo n.º 1
0
print()

mydata.print()

print('inorder traversal should be in sorted order ...')
print('the result should be : and, are, hello, how, peace, war, world, you')
print('the result is : ', end='')
for x in mydata:
    print(x, end=', ')
print()

print('search for "world", should be True : ', 'world' in mydata)
print('search for "and", should be True: ', 'and' in mydata)
print('search for "you", should be True : ', 'you' in mydata)
print('search for "me", should be False : ', 'me' in mydata)
print('find minimum "and", should be found : ', mydata.findMin())
print('find minimum "you", should be found : ', mydata.findMax())

mydata.remove('war')
print(
    'deleting "war", the result should be: and, are, hello, how, peace, world, you'
)
print('the result is : ', end='')
for x in mydata:
    print(x, end=', ')
print()

mydata.remove('world')
print(
    'deleting "world", the result should be: and, are, hello, how, peace, you')
print('the result is : ', end='')
Ejemplo n.º 2
0
from bst import BST, Node

bst = BST()
bst.add(3)
bst.add(4)
bst.add(6)
bst.add(8)
bst.add(1)
bst.add(9)
bst.add(2)
bst.add(12)
minimum = bst.findMin()
maximum = bst.findMax()
print(f'Min is: {minimum}')
print(f'Max is: {maximum}')