As defined in the chapter, the Family Tree Node structure uses a vector to store the children. Another possibility is to include an extra pointer in these nodes that will allow them to form a linked list of the children. Thus, in this design, each node in the tree needs to contain only two pointers: one to its eldest child and one to its next younger sibling. Using this representation, the House of Normandy appears as shown in Figure 16-9. In each node, the pointer on the left always points down to a child; the pointer on the right indicates the next sibling in the same generation. Thus, the eldest child of William I is Robert, which you obtain by following the link at the left of the diagram. The remaining children are linked together through the link cells shown at the right of the node diagram. The chain of children ends at Henry I, which has the value NULL in its next-sibling link. Using the linked design illustrated in this diagram, write new definitions of
Family Tree Node, read Family Tree, and display Family Tree.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here