3 Types Of Linked List Explained To Kids In An Easy Way

This post is also available in: हिन्दी (Hindi)

Linked Lists are the types of data structures used in computer programs for storing data. This text is about these 3 types of linked list explained to kids in an easy way.

Join the Dots

You might have done activities on “Join the dots” as shown below. In such activities, you start from a dot numbered as 1 and move to the one numbered 2 and then 3 and so on till the dot with the last number.

Types Of Linked List Explained To Kids In An Easy Way
Join the Dots

In such types of activities, you link one dot with the next dot because you know the number of the next dot. This is what happens in the Linked List.

A linked list is a type of data structure consisting of a number of nodes and each node “knows” the address of the next node.

What is a Linked List?

A linked list is a type of data structure where a set of information/data are linked together by references. The data are often called nodes. The references are often called links or pointers. 

In linked lists, any operation can be performed on data present in nodes (depending on their data type). Whereas, pointers can only be compared and incremented or decremented. You cannot perform any other operation on pointers. (Since pointers are addresses of the data and not the ordinary variables).

Types Of Linked List Explained To Kids In An Easy Way
Linked List

In the above figure, there are 4 nodes. The first node (containing 2) does not have any node pointing to it. Such a node is called the Head Node. The node containing 2 stores the address of the node containing 4, the node containing 4 stores the address of the node containing 6, and so on. The node containing does not store the address of the next node (instead it stores the NULL value). Such a node is known as Tail Node.

Applications of the Linked List

Some of the applications of the linked list are:

  • The images are linked with each other so that an image viewer software uses a linked list to view the previous and the next images using the previous and next buttons.
  • Web pages can be accessed using the previous and the next URL links which are linked using a linked list.
  • The music players also use a linked list to switch between music.
  • To keep the track of turns in a multi-player game, a circular linked list is used.

Types of Linked List

The three basic types of linked lists are:

1. Simple Linked List

The type of linked list you saw above is called a simple linked list. In a simple linked list, each node contains the data and address of the next node except the last node which contains only the data (the address part of the last node contains a NULL value).

In the case of a simple linked list, the traversal is in one direction only, i.e., from head to tail.

Structure of Simple Linked List in C++

Since every node of a simple linked list contains two values – data (can be of any data type) and address of the next node (pointer data type), therefore, the following code is used to create a node of a simple linked list:

struct Node {
   int data;
   struct Node *next;
};

2. Doubly Linked List

In a doubly-linked list, each node contains three sub-units

  • address of the previous node (pointer data type)
  • data (any data type)
  • address of the next node (pointer data)

The address of the previous node part of the head node contains a NULL value (indicating there is no node before it) and the address of the next node part of the tail node contains a NULL value (indicating there is no node after it).

In the case of a doubly-linked list, the traversal is in both directions, i.e., from head to tail and from tail to head.

Types Of Linked List Explained To Kids In An Easy Way
Doubly Linked List

In the above figure, there are 4 nodes. Each node has three sub-units – previous, data, and next. The first node (containing A) does not have any node pointing to it. Such a node is called the Head Node. The previous part of the head node stores a NULL value (there is no node before it). The next part of the head node contains the address of the next node (containing data B). Similarly, the previous part of node B contains the address of node A (previous node) and the next part of it contains the address of node C (next node). The next part of the last node called the tail node (containing D) contains a value NULL.

Structure of Doubly Linked List in C++

Since every node of a doubly-linked list contains three values – address of the previous node (pointer data type), data (can be of any data type), and address of the next node (pointer data type), therefore, the following code is used to create a node of a doubly-linked list:

struct Node {
   int data;
   struct Node *prev;
   struct Node *next;
};

3. Circular Linked List

In a circular linked list, the last element is linked to the first element and the first element has a link to the last element as previous. 

A circular linked list can be implemented either using a simple linked list or a doubly-linked list.

Types Of Linked List Explained To Kids In An Easy Way
Circular Linked List (Using Simple Linked List)
Types Of Linked List Explained To Kids In An Easy Way
Circular Linked List (Using Doubly Linked List)

Basic Operations Supported by Linked List

Following are the basic operations supported by a list.

  • Insertion − Adds an element at the given position of the list.
  • Deletion − Deletes an element at the given position of the list.
  • Display − Displays the complete list.
  • Search − Searches an element using the given key.

Leave a Comment