# To implement Queue using list
queueList = []
def enQueue(ele='\0'):
if ele!='\0':
queueList.append(ele)
print("enQueue operation successfully completed.")
else:
print("Operation failled.")
def deQueue():
if(len(queueList)>0):
queueList.remove(queueList[0])
print("deQueue operation successfully completed.")
else:
print("Operation failled.")
print("List is empty.")
while(True):
print("\n\nChoose one option : ")
print("1. enQueue operation,")
print("2. deQueue operation.")
print("3. Display List element.")
print("e. Exit")
op = input()
if op=='1':
ele = input("Enter element for PUSH operation.")
enQueue(ele)
elif op == '2':
deQueue()
elif op == '3':
if(len(queueList)>0):
print(queueList)
else:
print("List is Empty")
elif op == 'e':
break
else:
print("Choose correct option.")
If you have a great ability of thinking, imagination and visualisation than you have to codes your thinking and visualisation.
Friday, 15 June 2018
To implement Queue using list using python programming.
Subscribe to:
Post Comments (Atom)
Featured post
To add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3, leave it unchanged. <br/>Sample String : 'abc' <br/> Expected Result : 'abcing' <br/> Sample String : 'string'
#To add 'ing' at the end of a given string (length should be at least 3). If the #given string already ends with 'ing' then...
Popular Posts
-
# To implement Queue using list queueList = [] def enQueue(ele='\0'): if ele!='\0': queueList.append(...
-
# To find all prime numbers within a given range. import math n1 = int(input("Enter lower limit of range : ")) n2 = int(in...
-
# Python Program To demonstrate inheritance. # Parent Class class parentCls: def __init__(self): print("Parent Cl...
No comments:
Post a Comment