UMBC CS 201, Spring 02
UMBC CMSC 201 Spring '02 CSEE | 201 | 201 S'02 | lectures | news | help

Keeping Linked List Information

The head node

When working with lists, there seem to be certain items of information about the list that is common. Some of these things are: It is quite common to have another type of struct that holds this information about the list. It can increasse efficiency in the program by always keeping a total of some data members, etc.

Here's an example:

typedef struct node *NODEPTR; typedef struct node { int data; NODEPTR next; }NODE; /* Struct to keep info about the list */ typedef struct listInfo { int numNodes; int dataTotal; NODEPTR head; NODEPTR tail; } LISTINFO;


CSEE | 201 | 201 S'02 | lectures | news | help

Thursday, 17-Jan-2002 13:52:32 EST