Wednesday, September 24, 2025

DSA using Python: Assignment-6: Circular Doubly Linked List


This assignment focuses on implementing a Circular Doubly Linked List (CDLL) using Python. A CDLL is a data structure where each node contains references to both the previous and next nodes, and the list forms a closed loop. The assignment includes methods for insertion, deletion, searching, and traversal, demonstrating efficient manipulation of linked data in both forward and backward directions.

Assignment-6: Circular Doubly Linked List

🔹 Task 1: Define Node class
Define a class Node to describe a node of a circular doubly linked list.

🔹 Task 2: Define CDLL class with __init__() and is_empty()
Define a class CDLL to implement Circular Doubly Linked List with \_\_init\_\_() method to create and initialise last reference variable.

🔹 Task 3: Define is_empty() Method
Define a method is\_empty() to check if the linked list is empty in CDLL class.

🔹 Task 4: insert_at_start()
In class CDLL, define a method insert\_at\_start() to insert an element at the starting of the list.

🔹 Task 5: insert_at_last()
In class CDLL, define a method insert\_at\_last() to insert an element at the end of the list.

🔹 Task 6: search()
In class CDLL, define a method search() to find the node with specified element value.

🔹 Task 7: insert_after()
In class CDLL, define a method insert\_after() to insert a new node after a given node of the list.

🔹 Task 8: display()
In class CDLL, define a method to print all the elements of the list.

🔹 Task 9: Implement __iter__()
In class CDLL, implement iterator for CDLL to access all the elements of the list in a sequence.

🔹 Task 10: delete_first()
In class CDLL, define a method delete\_first() to delete first element from the list.

🔹 Task 11: delete_last()
In class CDLL, define a method delete\_last() to delete last element from the list.

🔹 Task 12: delete_item()
In class CDLL, define a method delete\_item() to delete specified element from the list.

No comments:

Post a Comment

Recursion in DSA using Python

Follow me If you want to understand with  Graphical Representation   click on it. You can find the explanatory video at the bottom of this p...