Singly Linked List
Singly Linked List
Here in the picture you can see that a linked list is composed mainly of nodes
and each node contains the address of its next connected node.
What is a Node?
A node is the main structure of the linked list. It contains all details about the
data and the address of next node. A node can contain many data fields and
many address fields, but should contain at least one address field. Address
part of last node contains a NULL value specifying end of the list. In computer
programming a node can be represented either by structures (struct in C or
C++) or by classes (class in C++ or Java) and address part of a node is
basically represented by pointers (in C and C++). Here is a basic structure of
a node in C programming language.
/*Basic structure of a node*/
struct node {
int data; // Data
struct node * next; // Address
};
Copy
Singly linked list is a basic linked list type. Singly linked list is a collection of
nodes linked together in a sequential way where each node of singly linked list
contains a data field and an address field which contains the reference of the
next node. Singly linked list can contain multiple data fields but should contain
at least single address field pointing to its connected next node.
To perform any operation on a linked list we must keep track/reference of the
first node which may be referred by head pointer variable. In singly linked list
address field of last node must contain a NULL value specifying end of the list.
struct node {
int data; // Data
struct node * next; // Address
};
Copy