https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files
Chapter 14 // Exercise 11
Define a Binary_tree class derived from Shape. Give the number of levels as a parameter (levels == 0) means no nodes, levels == 1 means one node, levels == 2 means one top node with two sub-nodes, levels == 3 means one top node with two sub-nodes each with two sub-nodes, etc). Let a node be represented by a small circle. Connect the nodes by lines (as is conventional). P.S. In computer science, trees grow downward from a top node (amusingly, but logically, often called the root).
Github: https://github.com/l-paz91/principles-practice/tree/master/Chapter%2014/Exercise%2011
My solution is disgusting and I'm not proud of it but I've already spent to long on this exercise. My problem is that I became obsessed with making sure all the nodes were perfectly spaced. As a result, if you go above a certain amount of levels it will go off the screen. I also wanted the nodes to be symmetrical.
No comments:
Post a Comment