UMBC CS 201, Fall 06
Fall '06

CSEE | 201 | 201 F'06 | 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 increase 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 F'06 | lectures | news | help

Tuesday, 22-Aug-2006 07:14:18 EDT