Linked List
Linked List
Introduction
• A linked list is a data structure which can change
during execution.
– Successive elements are connected by pointers.
– Last element points to NULL.
– It can grow or shrink in size during execution of a
program.
– It can be made just as long as required.
head
– It does not waste memory space.
A B C
• Keeping track of a linked list:
– Must know the pointer to the first element of the
list (called start, head, etc.).
Item to be
tmp X inserted
A B C
curr
X
Pseudo-code for insertion
tmp
curr
A B C
Programming and Data Structure 18
Spring 2012 Programming and Data Structure 19
Pseudo-code for deletion
typedef struct nd {
struct item data;
struct nd * next;
} node;
A B C
Doubly linked list
A B C