In all the classes for this assignment, use of the following Python language features is mandatory:
It is strongly recommended to read and understand http://docs.python.org/py3k/reference/datamodel.ht… and http://www.cafepy.com/article/python_types_and_obj….
The remainder of the class definition is left up to you.
import random import sys def main( ): if len(sys.argv) < 2: print('Please provide the number of keys to enter.') sys.exit(1) s = int(sys.argv[1]) parts = int(s/3) t = Tree( ) r = list(range(1,s+1)) print('Randomly inserting the numbers from 1 to {}.'.format(len(r))) random.shuffle(r) for i in r: print('inserted {}'.format(i)) t.insert(i) f = open('a.dot', 'w') writeTree(t, f) f.flush( ) f.close( ) random.shuffle(r) for n in range(1, 3): m = r[(n-1) * parts : (n * parts)] print(len(m)) for i in m: print('removed {}'.format(i)) v = t.remove(i) if v: print('tcompleted.') else: print('terror.') c = chr(n + 97) filename = str(c) + '.dot' f = open(filename, 'w') writeTree(t, f) f.flush( ) f.close( )
The output of the program is a file in DOT syntax. The output of your program must be passed to the program `dot`, part of Graph Viz, to create an visualization of your tree. An example output file is the following:
digraph BST{ node [fontname="Helvetica"]; 7 -> 2; 2 -> 1; null1 [shape=point]; 1 -> null1; null2 [shape=point]; 1 -> null2; null3 [shape=point]; 2 -> null3; 7 -> 9; null4 [shape=point]; 9 -> null4; null5 [shape=point]; 9 -> null5; }
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more