Header Ads Widget

Responsive Advertisement

DS All About Linked List In Data Structure.Types Of Linked List, Node, Singly Linked List, Doubly Linked List, Circular Linked List. C Programming Full Course Step by Step Part-18



 Linked Lists

What is a linked list?

Ans: A linked list is a linear data structure, in which the elements are not stored at a contiguous memory location.



A linked list is a dynamic data structure. The number of nodes in a list is not fixed and can grow and shrink on demand.

Each element is called a node which has two parts.

One is the information part which stores the information and the other is the pointer/address part which points to the next element.

 






 

There are three types of linked lists:

1. Singly linked list:

It is a linear collection of data items called nodes where each node has divided into two-part (data part & linked part) data part stores the data item and the link part stores the address of the next node.

Example: data = MILAN

address

data

link

1

I

4

2

 

 

3

N

Null

4

L

8

5

 

 

6

 

 

7

M

1

8

A

3

When we print the data:



The result is: MILAN

2. Doubly linked list:

It is a linear collection of data items called nodes where each node has divided into three-part (data part & previous part & next part) data part stores the data item, the previous part stores the address of the previous node, and the next part stores next node address.

It starts with a special pointer called the first pointer and ends with the last pointer

Example:

Data = ANISH (Forward & Backward)

 

Address

Previous

Data

Next

First

1

Null

A

2

 

2

1

N

3

 

3

2

I

4

 

4

3

S

5

Last

5

4

H

Null

When we print the data:

 


Result Forward: ANISH

Result Backward: HSINA

 

3. Circular linked list:

The circular linked list is the variety of linked lists where the first node points to the last node and the last node point to the first node.

Example:

Data = ABCD

Address

Data

Link

1

A

2

2

B

3

3

C

4

4

D

1

When we print the data:



Result: ABCD……….

 

There are two types of circular linked list

1. singly circular linked list



2. doubly circular linked list



Post a Comment

0 Comments