from bst import BST """ The test tree should look like: hello are world and how you war peace """ values = [ 'hello', 'world', 'how', 'are', 'you', 'war', 'and', 'peace' ] print( 'Original data ...' ) mydata = BST() for v in values: print( v, end = ', ' ) mydata.add( v, v ) # v is both key and data 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 maximum "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( 'Eeleting "world", the result should be: and, are, hello, how, peace, you' ) print( 'The result is : ', end = '' ) for x in mydata: print( x, end = ', ' ) print() print('Sorting in reverse order the data in BST') print(mydata.sort_reverse())