VOOZH about

URL: https://www.geeksforgeeks.org/dsa/menu-driven-program-to-implement-all-the-operations-of-doubly-circular-linked-list/

⇱ Menu Driven Program to implement all the operations of Doubly Circular Linked List - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Menu Driven Program to implement all the operations of Doubly Circular Linked List

Last Updated : 23 Jul, 2025

Circular Doubly Linked List has properties of both Doubly Linked List and Circular Linked List in which two consecutive elements are linked or connected by previous and next pointer and the last node points to the first node by next pointer and also the first node points to the last node by the previous pointer. The program implements all the functions and operations that are possible on a doubly circular list following functions in a menu-driven program.

Approach: Each function (except display) takes the address of the pointer to the head i.e. the first element of the list. This allows us to change the address of the head pointer. The idea is the use only one pointer, which is of type node, to perform all the operations. node is the class that contains three data members. One member is of type int which stores data of the node and two members of type node*, one store's address of next element and other stores address of the previous element. This way it is possible to traverse the list in either direction. It is possible to modify, insert, delete search for the element using a single pointer.

Functions Covered:

  • void insert_front (node **head): This function allows the user to enter a new node at the front of the list.
  • void insert_end (node **head): This function allows the user to enter a new node at the end of the list.
  • void inser_after (node **head): This function allows the user to enter a new node after a node is entered by the user.
  • void insert_before (node **head): This function allows the user to enter a new node before a node is entered by the user.
  • void delete_front (node **head): This function allows the user to delete a  node from the front of the list.
  • void delete_end(node**head): This function allows the user to delete a node from the end of the list.
  • void delete_mid( node **head): This function allows deletion of a node entered by the user.
  • void search (node *head): Function to search for the location of the array entered by the user.
  • void reverse (node **head): Function to reverse the list and make the last element of the list head.
  • void display (node *head): Function to print the list.

Below is the C++ program to implement the above approach:


Output:


1. void insert_front (node **head):


👁 Insert front node


2. void insert_end (node **head):


👁 Insert End


3.  void insert_after (node **head):


👁 Insert After


4.  void insert_before (node **head):


👁 Insert Before


5.  void delete_front (node **head):


👁 Delete Front


6.  void delete_end (node **head):


👁 Delete End


7.  void delete_mid (node **head):


👁 Delete Mid


8.  void search (node *head):


👁 Search


9.  void reverse (node **head):


👁 Reverse Node


Comment