Explain the concept of Linked list in C language


Before understanding the linked list, let us learn about the disadvantages of arrays and the advantages of pointers in C programming language.

Disadvantages of Arrays

  • It includes static memory allocation

  • Wastage of memory can be experienced in arrays.

  • Insufficiency of memory is one of the important disadvantage of arrays.

Advantages of pointers

  • It includes dynamic memory allocation.
  • Effective usage of memory can be experienced in pointers.

Linked Lists

Linked lists use dynamic memory allocation i.e. they grow and shrink accordingly. They are defined as a collection of nodes. Here, nodes have two parts, which are data and link. The representation of data, link and linked lists is given below −

Types of Linked Lists

Linked lists have four types, which are as follows −

  • Single / Singly linked lists
  • Double / Doubly linked lists
  • Circular single linked list
  • Circular double linked list

Single linked list

Refer the representation given below −

Node consists of two parts, which are as follows −

  • Data
  • Link

The link field always point to the next node in the list.

The link field of the last node is null.

Double linked list

Refer the representation given below −

Node consists of three parts namely

  • Data part
  • Left link
  • Right link

The left link always points to the left node in the list and the right link always points to the right node in the list.

The left link of the first node and the right link of the last node must be Null.

Circular single linked list

Refer the representation given below −

Node consists of two parts, namely,

  • Data part
  • Link part

The link field always points to the next node in the list.

The link part of the last node always points to the first node.

Circular double linked list

Refer the representation given below −

Node consists of three parts, namely,

  • Data part
  • Left link
  • Right link

Left link always points to the left node in the list and the right link points to the right node in the list.

The left link of the first node points to last node & right link of the last node points to the first node.

Updated on: 24-Mar-2021

303 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements