Skip to content

Instantly share code, notes, and snippets.

@computer-tutor
Created April 25, 2020 11:03
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
def enqueue(queue,x):
queue.append(x)
def dequeue_f(queue):
return queue.pop(0) #dequeues element present at front end
def dequeue_r(queue):
return queue.pop() #dequeues element present at rear end
l=[]
front =0
enqueue(l,1)# l=[1]
print(l)
enqueue(l,2)# l=[1,2]
print(l)
enqueue(l,3)# l=[1,2,3]
print(l)
enqueue(l,4)# l=[1,2,3,4]
print(l)
enqueue(l,5)# l=[1,2,3,4,5]
print(l)
print(dequeue_f(l))# 1 deleted
print(dequeue_r(l))# 5 deleted
print("Final list after dequeue: ", l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment