Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Linked lists.

Node:Linked lists, Next:, Previous:Lists and trees, Up:Lists and trees



Linked lists.

A linked list is a linear sequence of structures joined together by pointers. Each node's pointer links to the next node in the sequence. Linked lists have two main advantages over one dimensional arrays: they can be sorted easily simply by redirecting pointers, and they can be made any length at all dynamically.

Here is an example of a structure type from a linked list:

struct list_node
{
  double value;
  struct list_node *next;
};

Here the value member holds the actual content of the node, in this case a double-precision floating-point number, and the next member points to the next node in the list.

You will often encounter another basic kind of linked list, called a doubly-linked list. Each node in a doubly-linked list contains not only a pointer to the next node, but also to the previous node. This kind of list makes it easier to determine what the node preceding a node is, as well as the node succeeding it.

 
 
  Published under free license. Design by Interspire