Skip to content

Commit

Permalink
Update Queue.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrow1997 authored Oct 1, 2017
1 parent 815ada7 commit 5be775d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Python implementation DataStructures/Queue.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
#List Based Implementation Of Queue in Python.


#Defining a python Class named Queue.

# isEmpty -> Returns True or False.
# enqueue -> Enter the element in Queue.
# dequeue -> Remove the element from Queue.
# size -> Returns the size of Queue

class Queue:

def __init__(self):
def __init__(self):
self.items = []

def isEmpty(self):
def isEmpty(self):
return self.items == []

def enqueue(self, item):
def enqueue(self, item):
self.items.insert(0,item)

def dequeue(self):
def dequeue(self):
return self.items.pop()

def size(self):
def size(self):
return len(self.items)


q=Queue()
#Create an object of Class Queue

q.enqueue(4)
q.enqueue('dog')
Expand Down

0 comments on commit 5be775d

Please sign in to comment.