So today, I finally got myself to start working on the Object System. After not programming for a little over a month, I kept pushing it under the blanket for fear of not remembering anything. Fortunately though (or at least in this case) programming is like riding a bike.
I wrote the node class and header for the tree class; ready to start implementing the latter. Thankfully, node builds! A good and hopeful start;-) I'm still a little confused about the tree's create method though. I know this sounds silly because you would think it does what its name suggests, but what exactly constitutes creating a tree? In the pseudo-code to call functionality that was distributed with the first assignment, the first call is to create a tree. Afterwards, it is destroyed, and then a node is inserted, so our tree now consists of:
a) 1 Node: the node that is inserted is the parent node and so we set it to be the root node and nullify its parent pointer?
or
b) 2 Nodes: the parent and a node that is now a child of that parent (this child is the inserted node). If case B is indeed the right approach, that assumes that create tree creates a root node and sets all of the info about the tree, like a constructor of sorts.
Actually, now that I have written this out and had this discussion with myself, it is starting to make more sense, and I am liking approach B. I already have my info struct set up and have a pointer to it in my tree class, so it lends itself well to this sort of implementation. I'll try it out later tonight or tomorrow and see! I have a feeling that this is the part of the coding process that will require a lot of diagramming.
No comments:
Post a Comment