by Dinesh Thakur Category: Linked Lists

A more sophisticated kind of linked list is a doubly-linked list or a two-way linked list. In a doubly linked list, each node has two links: one pointing to the previous node and one pointing to the next node.

Node structure

Implementation of a doubly linked list

Adding an element to the list

To add the first node

first_node->next = NULL;

first_node->data = input_element;

first_node->prev = NULL;

To add a node at the position specified

Temp_node = *first_node;

for ( counter = 0 ; counter<position-1 ; counter++ )

{

Temp_node = Temp_node->next;

}

new_node->next = temp_node->next;

temp_node->next->new_node;

new_node->prev = temp_node->next->prev;

temp_node->next->prev = new_node;

Deleting a particular element from the list

Temp_node = *first_node;

If ( temp_node->data = = input_element )

First_node = first_node->next;

else

{

while ( temp_node != NULL && temp_node->next->data !=

input_element)

temp_node = temp_node -> next;

delete_node=temp_node->next;

temp_node->next=delete_node->next;

delete_node->next->prev=temp_node;

free(delete_node);

}

About Dinesh Thakur

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Search Content

Popular Article

#### What is Linked lists? How Many Type of Link List

#### Short Note on Singly Circular Linked List

#### What is Doubly Linked List

#### What is Circular Linked Lists

#### Short Note on Single Linked List

#### What is Linked Lists

#### What is Doubly-circularly-linked list

#### Circularly-linked list vs. linearly-linked list

#### What is Singly-circularly-linked list

Basic Courses

Advance Courses

- Advantages And Disadvantages Of Computer
- What is Hard Disk Drive (HDD)?
- What is Router | Definition of Router
- Routers – What is Router? Characteristics of Routers. Router Protocols
- What is Software | Type of Software | Definition of Software
- What is CPU | CPU Definition | CPU Meaning
- What is LAN (Local Area Network) | Definition of LAN