This code is an implementation of the binary search tree shown in class, with slides beginning here.
Write your answers into the studio10.txt file in the studiowriteups folder.A1. Why do sad and happy appear as they do? Why is happy indented? What are the parent, left-child, and right-child relationships between happy and sad?
Modify the code in the main method so that some string appears above sad, indented as much as happy.
A2. What string did you use?
In the numbers that follow, find the first (smallest) and last (largest) entries in the tree that is shown (on its side, as discussed in lecture).
A3. Is the first number always the first line to be shown in such a display?
A4. Is the last number always the last line to be shown?
A5. Why do we need insertHelper?A6. Why is it private instead of public?
A7. Does the code actually remove the node containing the value to be removed? If not, what is actually happening?
// Why does this code fail? // // BST<Color> col = new BST<Color>(new Ticker()); // col.add(Color.RED); // col.add(Color.BLUE);Uncomment that code, and then run the code.
A8. Why does the code fail to execute properly?A9. Why does eclipse not report a problem when you try to create a BST of type Color?
Remember to refresh the outputs folder so you can see the new files generated.
B1. What behavior do you see in the output? You will likely have to rely on ticks rather than time, because the times are so fast.B2. What behavior did you expect to see, and why?
new IntArrayGenerator(), /* new IntSequenceArrayGenerator(), */to
/* new IntArrayGenerator(), */ new IntSequenceArrayGenerator(),which will provide an integer sequence as input.
Rerun the SortedSetUsingBST program, refresh outputs and look at the newest time and ticks files.
B3. What behavior do you see in the output given the sorted input?B4. What behavior did you expect to see, and why?
B5. What behavior do you see in the output when a sorted set is implemented by an unordered list? Adding to the list should be quick, so why are we seeing these times?B6. What behavior did you expect to see, and why?
When you done with this studio, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
This demo box is for studio 10