Assignment 5 Hints * All output for your program must be Xtango commands. If you want to print debugging output to the xterm, then use the command "comment" with an "endl" at the end. This command is ignored by the animator and instead outputs what follows comment to the xterm window. To generate output using this command type: cout << "comment " << .... << endl; For example: cout << "comment " << "Value of x is " << x << endl; * Look at the output file to see the Xtango commands I created. You don't have to create the same ones, but it might be helpful in getting started. For example, the first thing you will want to do is to declare the size of the window. I declared mine to be 75 by 75. You can pick another size if you want. * Sketch out on paper the placement of your nodes in the binary tree, assuming the tree is complete. Then come up with a formula for the position when you insert a node. Start with the x and y positions of the root and adjust these values as the node moves down levels and whether or not you move to the left or to the right. * Creating a mintree. Idea: Consider a node, if it is not smaller than its two children then swap the node with the smaller of its two children. Start at the bottom of the tree and slowly move up the tree, so that two subtrees of a node are mintrees first and then you process the node. In processing the node, if you do a swap, then you may "upset" the subtree that you swapped with, but walking down one path should fix it up. Try writing out an example on paper. * You can assume that no more find or insert commands will occur after a mintree command occurs. You can also assume that the deletemin command only occurs after the mintree command. * Your deletemin command should be efficient. It should do the minimal work to reorganize the tree. This command removes the node at the root of the tree. At that point, note that the tree is mostly a mintree. One way to do this efficiently is to move the root value down a path to a leaf, fixing up the tree as you move down the path, then delete the node once it is a leaf. * All coordinates MUST BE real numbers. If you output the real number 6.0 it may be output as 6 since there are no digits to the right of the decimal, and Xtango won't be happy. Make sure you output real numbers by either specifying to print 1 place after the decimal or working with integers and outputting ".0" after each int. If x is an int, then: cout ... << x << ".0 " ... * You might want to add other info to the node definition. For example you might want info as to where the node is drawn in the picture, or the identifying tags associated with the node and data item. I drew my nodes as circles but you can draw them some other way, or color them in. Each object created in Xtango has a unique tag associated with it. You'll need to generate this tag and in some cases may need to keep track of it. For example, in the mintree operation if you decide to swap two values, say 5 and 9, you will need to know their unique tag when they were created in order to swap them in the animation.