Difference between revisions of "CSC212 Homework 6 2014"
(→Problem #1) |
(→Problem #1) |
||
Line 17: | Line 17: | ||
* It doesn't need any parameters passed to it. | * It doesn't need any parameters passed to it. | ||
* It outputs your name as a label. | * It outputs your name as a label. | ||
− | * Here is an example of the type of output it will generate for a given tree: | + | * Here is an example of the type of output it will generate for a given tree, for User Mickey Mouse: |
<br /> | <br /> | ||
::<source lang="dot"> | ::<source lang="dot"> |
Revision as of 18:52, 30 October 2014
--D. Thiebaut (talk) 12:17, 30 October 2014 (EDT)
This assignment is due Friday Nov 7, 2014, at 11:55 p.m.
Problem #1
- Add a new method to your BST program that will output the DOT version of the tree it contains. Refer to Lab 10 for how we generate the DOT version of a tree.
- Your function must be called generateDot()
- It must be public so that my test program can access and use it
- It doesn't need any parameters passed to it.
- It outputs your name as a label.
- Here is an example of the type of output it will generate for a given tree, for User Mickey Mouse:
digraph T { label = "Mickey Mouse"; 8 -> 3; 8 -> 10; 3 -> 1; 3 -> 6; 6 -> 4; 6 -> 7; 10 -> 14; 14 -> 13; }
Submission to Moodle
- Submit IntBST.java to Moodle, Problem 1 of Homework 6.
Problem #2
- The tree generated in the first problem is not balanced well when the number of children is 1.
- Modify your generateDot() function so that it outputs "invisible nodes" for null children.
- Here is an example of the type of output to expect from your function for the same tree:
digraph T { label = "Mickey Mouse"; 8 -> 3; 8 -> 10; 3 -> 1; 3 -> 6; null1left [label="",width=.1,style=invis]; 1 -> null1left [style=invis]; null1right [label="",width=.1,style=invis]; 1 -> null1right [style=invis]; 6 -> 4; 6 -> 7; null4left [label="",width=.1,style=invis]; 4 -> null4left [style=invis]; null4right [label="",width=.1,style=invis]; 4 -> null4right [style=invis]; null7left [label="",width=.1,style=invis]; 7 -> null7left [style=invis]; null7right [label="",width=.1,style=invis]; 7 -> null7right [style=invis]; null10left [label="",width=.1,style=invis]; 10 -> null10left [style=invis]; 10 -> 14; 14 -> 13; null14right [label="",width=.1,style=invis]; 14 -> null14right [style=invis]; null13left [label="",width=.1,style=invis]; 13 -> null13left [style=invis]; null13right [label="",width=.1,style=invis]; 13 -> null13right [style=invis]; }
Submission
- Submit your IntBST.java program to Moodle, Problem 2 of Homework 6 section.
Problem 3
...Stay tuned... will be provided later...