DS Lab Assignment3
DS Lab Assignment3
CODE
class Node:
"""A class to represent a node in a circular linked list."""
def __init__(self, data):
self.data = data
self.next = None
class CircularLinkedList:
"""A class to represent a circular linked list."""
def __init__(self):
self.tail = None # Tail points to the last node in the
circular list.
def is_empty(self):
"""Check if the list is empty."""
return self.tail is None
def display(self):
"""Display all elements in the circular linked list."""
if self.is_empty():
print("The list is empty.")
return