Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. class Node:
  2. def __init__(self,val):
  3. self.val=val
  4. self.next=None
  5.  
  6. class Queue:
  7. def __init__(self):
  8. self.start_node=None
  9.  
  10. def push(self, val):
  11. node=Node(val)
  12. if self.start_node==None:
  13. self.start_node=node
  14. else:
  15. cur=self.start_node
  16. while cur.next != None:
  17. cur=cur.next
  18. cur.next=node
  19. def pop(self):
  20. self.start_node=self.start_node.next
  21. def front(self):
  22. return self.start_node.val
  23.  
  24. q = Queue()
  25.  
  26. q.push(5)
  27. q.push(7)
  28. print(q.front())
  29. q.pop()
  30. print(q.front())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement