CS 102 Laboratory Session Twelve

General Tree Implementation with a Linked List

This is the week Fifteen (last) Lab session, worth 5 points total. It may require a small amount of advanced preparation, such as reviewing the linked list toolkit (chapter 5 of MS) and templates (chapter 6 of MS).

You will need to download the following files:

  • TreeDemo.cpp (program to create and search a general tree).
  • TreeNode.h (header file that defines a general tree node class).
  • TreeNode.cpp (implementation file for the general tree node class).
  • link2.h (header and implementation file combined for a linked list toolkit).
  • The TreeDemo program as downloaded uses a TreeNode that is implemented with an array to hold the TreeNode children. Modify the TreeNode class to use a linked list instead. You will need to include link2.h in the TreeNode.h file.

    You will need to modify the TreeNode member functions (such as addChild() and findChild()) to use the linked list toolkit. You should not have to make any changes to TreeDemo.cpp.



    This page established November 1, 1999; last updated November 26, 1999 by Rick Wagner.