CS 240
Lab 10

Purpose:  To explore some advanced variants of pointer-based linked lists.

Reading:  Linked lists with head nodes are discussed on pp. 586-589.  Circular linked lists, with and without head nodes, are discussed on pp. 589-591.  Multiply-ordered linked lists are discussed on pp. 631-632.

Assignment: 
We have already implemented an ordered, pointer-based, simple linked list in lab 3.  We have seen that this type of data structure can expand or contract as needed, can maintain its elements in  an ordered manner, can allow sequential access to its elements, and can allow insertion and deletion  of elements without any shifting.

The file LinkedList.h contains a template for the kind of simple linked list described above (LinkTester.cpp has also been provided so that you can try it out if you like  However, please write your own testers for the following!).  In this lab you will copy and rename this file for each step, then modify it as directed below.
  1. Linked list with head node (HeadNodeList.h):  Since the first node in a simple linked list does not have a predecessor, insertion to either an empty list or to the front of the list requires special logic.  It follows, therefore, that if it were possible for every node to have a predecessor, this special logic would be unnecessary.  This is the rationale behind using a dummy first node, called a head node, at the beginning of a list. 
  1. Circular linked list (CircularList.h):  It is sometimes useful to insure that every node has both a predecessor and a successor, except when the list is empty.  This can be accomplished by making the last node in a linkedlist point to the first node in the list (instead of pointing to NULL).  Construction of this circular linked list will simplify some operations, while requiring special consideration for others.
  1. Circular linked list with head node (CircularHeadNode.h):  Many of the above special considerations are simplified if a circular linked list is constructed with a head node.
  1. Multiply-Ordered list(MultiplyOrderedList):  A simple linked list is ordered by a single data field.  It is not unusual, however, for a list element to contain several pieces of data, each of which could be ordered with its own next field.