CSLL (Cyclic Singly Linked List)
struct node {
eltType elt; /* field to store an element */
struct node* next; /* pointer to the next node */
};
typedef struct node listNode;
typedef listNode* listPtr;
typedef listPtr list;
list L; /* L is a variable of type list */
/* L is a pointer to some listNode */
Since the list is cyclic each node can be reached from any arbitrarily chosen node. Thus, the access pointer can be
a pointer to any node in the list and the notion of first is no longer strictly needed. This also holds for the CSLL
defined with a header node. Sometimes however the notion of first and last is convenient and in that case last will
give access to the list and first is the successor of last.
struct node {
eltType elt; /* field to store an element */
struct node* next; /* pointer to the next node */
};
typedef struct node listNode;
typedef listNode* listPtr;
typedef header {
listPtr cur;
listPtr last;
int size;
};
typedef struct header listHeader;
typedef listHeader* list;
list L; /* L is a variable of type list */
/* L is a pointer to the header node */
|