class Queue: def __init__(self): self.values = [] def enqueue(self, x): self.values.append(x) def dequeue(self): if not self.is_empty(): return self.values.pop(0) # Remove and return the first element else: raise IndexError("dequeue from empty queue") def is_empty(self): return len(self.values) == 0 If list is already empty then how will you pop, to handle that.
sir pgt computer science k notes mil skte h apke bnye hue ......ap boht achha pdate ho mujhe or kisi ka pdaya huaa smjh nhi aata sirf apki class smjh aati h
sir your videos are very important for me your teaching style is awesome
You are always explain well ❤❤❤❤❤❤❤🎉🎉🎉🎉🎉
Clear logic delivered, thanks.
I made some changes in your code and it is working fine and is more easy to understand:
class Queue:
def __init__(self):
self.values = []
def enqueue(self, x):
self.values.append(x)
def dequeue(self):
self.values.pop(0)
def peek(self):
print(self.values[0])
class Queue:
def __init__(self):
self.values = []
def enqueue(self, x):
self.values.append(x)
def dequeue(self):
if not self.is_empty():
return self.values.pop(0) # Remove and return the first element
else:
raise IndexError("dequeue from empty queue")
def is_empty(self):
return len(self.values) == 0
If list is already empty then how will you pop, to handle that.
Thanks ❤❤❤❤
Nice video thank you sir
Sir aapkiski teyari krvate ho.... Tell me plz...
Sir I am so so so impressed by your learning methods i haven't word for explain my feelings.
Sir graph,tree, hashing ka bhi video bano sir ji❤❤❤❤
Sir implementation of queue using array and link list ka lecture explain kr day plzzz🙏
sir linear algebra ka playlist ni h ??
sir pgt computer science k notes mil skte h apke bnye hue ......ap boht achha pdate ho mujhe or kisi ka pdaya huaa smjh nhi aata sirf apki class smjh aati h
Hi sir
I am rama from Ramareddymathsacademy
How can I contact you
Hello! You can mail us at gatesmashers2018@gmail.com
why can't we use pop(0) as we have used in the stack why front variable and slicing small dout..
Sir this is good but, you should mention that dequeue in your implementation is O(n) time complexity.
❤
[1:]