Single Linked List

Type of LinkedList where each node knows only about its left or right neighbor.

C example: (CeeLanguage)

 /* An example of SingleLinkedList */

struct node { struct node *next; void *data; };

static struct node* new_node (void *data, struct node *next) { struct node *new; new = malloc (sizeof (struct node)); new->next = next; new->data = data; return new; }


A cool technique to go with this is to use a node** as an iterator, not the obvious node*. You keep your node** pointing to the next of the previous node (or to the head node*), so that when you iterate along a list looking for something, you haven't hurtled past it by the time you find it. -- BillWeston


A ConsCell in LispLanguage is essentially a node in a SingleLinkedList.


CategoryDataStructure


EditText of this page (last edited January 22, 2005) or FindPage with title or text search