Data Structure : Introduction to Linked List

Summary


What is Linked list

Linked list is a ADT(Abstract Data Type) consisting of group of nodes in a connected way forming a sequence. A linked list is used to maintain dynamic series of data. Each node of a linked list basically contains only two parts data part and the address part. Data part of the node hold the actual data while the address part of the node holds the reference or address to its next connected node. Linked list got its name because here each list (node) is linked to another list (node).
Linked list logical diagram
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.

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 part
    struct node * next; //Address part
};

Advantages of linked list


Disadvantages of linked list



Labels: ,