Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class Node: def __init__(self, value): self.value = value self.next = None def __str__(self): return Node({}).format(self.value) __repr__ = __str__ class Queue: ''' >>> x=Queue() >>> x.isEmpty()
class Node:
def __init__(self, value):
self.value = value
self.next = None
def __str__(self):
return "Node({})".format(self.value)
__repr__ = __str__
class Queue:
'''
>>> x=Queue()
>>> x.isEmpty()
True
>>> x.dequeue()
'Queue is empty'
>>> x.enqueue(1)
>>> x.enqueue(2)
>>> x.enqueue(3)
>>> x.dequeue()
1
>>> print(x)
Head:Node(2)
Tail:Node(3)
Queue:2 3
'''
def __init__(self):
self.head=None
self.tail=None
def __str__(self):
temp=self.head
out=[]
while temp:
out.append(str(temp.value))
temp=temp.next
out=' '.join(out)
return ('Head:{} Tail:{} Queue:{}'.format(self.head,self.tail,out))
__repr__=__str__
def isEmpty(self):
#write your code here
def __len__(self):
#write your code here
def enqueue(self, value):
#write your code here
def dequeue(self):
#write your code here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started