All technological notes.
Queue
rear, and the removal of existing items occurs at the other end, commonly called the front.The most recently added item in the queue must wait at the end of the collection. The item that has been in the collection the longest is at the front.
First-in first-out (FIFO)

Enqueue
Dequeue
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Queue:
def __init__(self, value):
new_node = Node(value)
self.first = new_node
self.last = new_node
self.length = 1
def print_queue(self):
temp = self.first
while temp is not None:
print(temp.value)
temp = temp.next
O(1)def enqueue(self, value):
new_node = Node(value)
if self.first is None:
self.first = new_node
self.last = new_node
else:
self.last.next = new_node
self.last = new_node
self.length += 1
O(1)def dequeue(self):
if self.length == 0:
return None
temp = self.first
if self.length == 1:
self.first = None
self.last = None
else:
self.first = self.first.next
temp.next = None
self.length -= 1
return temp
class Queue(object):
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def size(self):
return len(self.items)
def peek(self):
return self.items[0]
def push(self, obj):
self.items.append(obj)
def pop(self):
return self.items.pop(0)
print("\n--------Create--------\n")
s = Queue()
print("isEmpty\t", s.isEmpty()) # isEmpty True
print("\n--------Add--------\n")
s.push(1)
s.push("two")
print("peek\t", s.peek()) # peek 1
print("size\t", s.size()) # size 2
print("isEmpty\t", s.isEmpty()) # isEmpty False
print("\n--------Remove--------\n")
print("pop\t", s.pop()) # pop 1
print("pop\t", s.pop()) # pop two
print("size\t", s.size()) # size 0
print("isEmpty\t", s.isEmpty()) # isEmpty True