hmm, and that is something i could learn in a couple days? xP
I don't mean that to sound impatient but i want to lean things at maybe 1-2 items at a time not 4-5 unless they are all simple things because i am still learning.
Printable View
hmm, and that is something i could learn in a couple days? xP
I don't mean that to sound impatient but i want to lean things at maybe 1-2 items at a time not 4-5 unless they are all simple things because i am still learning.
The networking part probably requires a pretty specific tut and would have you copy & paste too much for much benefit. Let's skip that thought for now.
Let's study data structures a bit!
* The program asks for an integer n and then builds a tree structure so that n times a child node is added to any of the previously added nodes (randomly chosen where), the program begins with one ready root node.
* Asks for two integers, these are two ID's for nodes in the tree, and will search the tree to find out how closely they are related (ie. how many levels up the tree you have to go to find the first common parent node).
For this "homework assignment" I recommend at least: struct for each node, new keyword for dynamically creating those new items, pointers to parent & children from each node, some data structure to store pointers to every node so that you can find them by indexing (vector, set..).
so what exactly do you want me to do?
Do you mean you didn't understand my program description? Which part? It's not a very visual or interactive program, but introduces some very essential concepts.
i mostly didn't understand any of it. :P
Ok, let's make it a little more "practical"...
The program keeps record of a family tree. It recognizes two commands:
A <personA> <personB> : Adds personA as personB's child
O <person> : Outputs the names of person's parent and all children
In order to make it a legit tree structure, every new child must have a parent, except at startup there is only 1 person named alex, who has no parent. Obviously, the first child then must have alex as their parent. The next can have either alex or the one first created. There must be no limit to how many persons can be added, or how many children a person can have.
Plus points for implementing extra commands for saving and restoring a family tree!
For this program, making a child only takes one parent, but don't let it bother you. :)
It's essentially the same program as my previous suggestion, so look up from there.
Basically he's saying practice the concept of linkedlists :) so you may want to take a look at that