Difference between revisions of "CSC212 Homework 6 2014"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- <br /> <br /> __TOC__ <br /> <br /> <br /> <bluebox>This assignment is due Friday Nov 7, 2014, at 11:55 p.m.</bluebox> <br /> <br /> =Problem #1= <br /> * Add a ne...")
 
(Problem #1)
Line 19: Line 19:
 
* 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:
 
<br />
 
<br />
<source lang="dot">
+
::<source lang="dot">
 
digraph T {
 
digraph T {
 
label = "Mickey Mouse";
 
label = "Mickey Mouse";
Line 33: Line 33:
 
</source>
 
</source>
 
<br />
 
<br />
 +
==Submission to Moodle==
 +
<br />
 +
* Submit '''IntBST.java''' to Moodle, Problem 1 of Homework 6.
 +
<br />
 +
=Problem #2=
 +
<br />
 +
* 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:
 +
<br />
 +
::<source lang="dot">
 +
digraph T {
 +
label = "CSC212 -- BST";
 +
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];
 +
}
 +
</source>
 +
<br />
 +
==Submission==
 +
<br />
 +
* Submit your IntBST.java program to Moodle, Problem 2 of Homework 6 section.
 +
<br />
 +
=Problem 3=
 +
<br />
 +
...Stay tuned... will be provided later...
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
[[Category:CSC212]][[Category:Homework]]

Revision as of 11:22, 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 have 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:


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 = "CSC212 -- BST";
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...