Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node:
- def __init__(self,val):
- self.val=val
- self.next=None
- class Queue:
- def __init__(self):
- self.start_node=None
- def push(self, val):
- node=Node(val)
- if self.start_node==None:
- self.start_node=node
- else:
- cur=self.start_node
- while cur.next != None:
- cur=cur.next
- cur.next=node
- def pop(self):
- self.start_node=self.start_node.next
- def front(self):
- return self.start_node.val
- q = Queue()
- q.push(5)
- q.push(7)
- print(q.front())
- q.pop()
- print(q.front())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement