0% found this document useful (0 votes)
49 views2 pages

CLL Py

The document contains a Python implementation of a circular linked list (CLL) with methods for appending, displaying, searching, and removing nodes. It defines a 'node' class for individual elements and a 'cll' class for managing the list. The program includes a user interface for interacting with the CLL through a command-line menu.

Uploaded by

Ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views2 pages

CLL Py

The document contains a Python implementation of a circular linked list (CLL) with methods for appending, displaying, searching, and removing nodes. It defines a 'node' class for individual elements and a 'cll' class for managing the list. The program includes a user interface for interacting with the CLL through a command-line menu.

Uploaded by

Ms
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

class node:

def __init__(self,data):
[Link]=data
[Link]=None
[Link]=None

class cll:
def __init__(self):
[Link]=None
[Link]=None

def display(self):
temp=[Link]
if temp==None:
print("linkly list is empty ")
return
while temp:
print([Link])
if temp==[Link]:
break
else:
temp=[Link]

def search(self,key):
temp=[Link]
if temp==None:
print("Linked list is empty ")
return
while temp:
if [Link]==key:
print("Key found")
break
elif temp==[Link]:
print("Key not found ")
break
else:
temp=[Link]

def append(self,newnode):
if [Link]==None:
[Link]=newnode
[Link]=newnode
else:
temp=[Link]
[Link]=newnode
[Link]=temp
[Link]=newnode
[Link]=[Link]

def remove(self,key):
temp=[Link]
if temp==None:
print("Linked list is empty")
return
while temp:
if [Link]==key:
if [Link]==[Link]:
[Link]=None
[Link]=None
break
elif temp==[Link]:
[Link]=[Link]
break
elif temp==[Link]:
[Link]=[Link]
break
temp=[Link]
if temp==[Link]:
print("Key not found")
break

cLL=cll()
while 1:
print("\n [Link] \t [Link] \t [Link] \t [Link]
\n")
choice=int(input("Enter your choice : "))
if choice==1:
data=int(input("Enter an element to insert :"))
[Link](node(data))
elif choice==2:
[Link]()
elif choice==3:
key=int(input("Enter key to search : "))
[Link](key)
elif choice==4:
key=int(input("Enter key to delete :"))
[Link](key)
else:
break

You might also like