Menu driven program for all operations on doubly linked list in C
A Linked List is a linear data structure that consists of two parts: one is the data part and the other is the address part. A Doubly Linked List in contains three parts: one is the data part and the other two are the address of the next and previous node in the list. In this article, all the common operations of a doubly linked list is discussed in one menu-driven program. Show Operations to be performed:
Below is the implementation of the above operations: C
Output: Menu: Insertion at the starting: Insertion at the end: Insertion at specific position: Print the Linked List: Delete the first and last element with choice 5 and 6: Article Tags : C Programs Linked List Technical Scripter Technical Scripter 2020 Practice Tags : Linked List Doubly linked listDoubly linked list is a complex type of linked list in which a node contains a pointer to the previous as well as the next node in the sequence. Therefore, in a doubly linked list, a node consists of three parts: node data, pointer to the next node in sequence (next pointer) , pointer to the previous node (previous pointer). A sample node in a doubly linked list is shown in the figure. A doubly linked list containing three nodes having numbers from 1 to 3 in their data part, is shown in the following image. In C, structure of a node in doubly linked list can be given as : The prev part of the first node and the next part of the last node will always contain null indicating end in each direction. In a singly linked list, we could traverse only in one direction, because each node contains address of the next node and it doesn't have any record of its previous nodes. However, doubly linked list overcome this limitation of singly linked list. Due to the fact that, each node of the list contains the address of its previous node, we can find all the details about the previous node as well by using the previous address stored inside the previous part of each node. Doubly Linked ListIn this tutorial, you will learn about the doubly linke list and its implementation in Python, Java, C, and C++. A doubly linked list is a type of linked list in which each node consists of 3 components:
Note: Before you proceed further, make sure to learn about pointers and structs. Doubly Linked List Program in CAdvertisements Previous Page Next Page Doubly Linked List is a variation of Linked list in which navigation is possible in both ways, either forward and backward easily as compared to Single Linked List. C Program to implement double linked listWrite a C Program to implement double linked list operations.Here’s simple Menu Driven C Program to implement double linked list operations like Creation, Insertion, Deletion, Display, Count, Add Node, Delete Node, Search, Reverse, etc. in C Programming Language. OUTPUT:DOUBLY LINKED LIST IMPLEMENTATION OF LIST ADT 1. INSERT 2. DELETE 3. FIND 4. PRINT 5. QUIT Enter the choice :: 1 Enter the element to be inserted :: 10 Enter the position of the element :: 1 1. INSERT 2. DELETE 3. FIND 4. PRINT 5. QUIT Enter the choice :: 1 Enter the element to be inserted :: 20 Enter the position of the element :: 2 1. INSERT 2. DELETE 3. FIND 4. PRINT 5. QUIT Enter the choice :: 1 Enter the element to be inserted :: 30 Enter the position of the element :: 3 1. INSERT 2. DELETE 3. FIND 4. PRINT 5. QUIT Enter the choice :: 4 The list element are :: 10 -> 20 -> 30 -> 1. INSERT 2. DELETE 3. FIND 4. PRINT 5. QUIT Enter the choice :: 3 Enter the element to be searched :: 20 Element exist!!! 1. INSERT 2. DELETE 3. FIND 4. PRINT 5. QUIT Enter the choice :: |