master-algorithms-py/stacks_and_queues
2023-07-16 17:35:14 -07:00
..
Queue.py Add some cool queue, stacks, strings, math, bit manipulation examples (#35) 2023-07-16 17:35:14 -07:00
README.md Add some cool queue, stacks, strings, math, bit manipulation examples (#35) 2023-07-16 17:35:14 -07:00
Stack.py Add some cool queue, stacks, strings, math, bit manipulation examples (#35) 2023-07-16 17:35:14 -07:00

stacks and queues


Queues.py


> python3 queues.py

🧪 Testing Queue...
Is the queue empty? True
Adding 1 to 10 in the queue...
Queue: [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

Queue size: 10
Queue peek : 1
Is the queue empty? False

Dequeue...
Queue: [10, 9, 8, 7, 6, 5, 4, 3, 2]

Queue size: 9
Queue peek: 2
Is the queue empty? False


🧪 Testing Priority Queue...
Priority Queue: [(-4, 1, Item 4), (-1, 0, Item 1), (-3, 2, Item 3)]
Pop: Item 4
Priority Queue: [(-3, 2, Item 3), (-1, 0, Item 1)]

stack.py


python3 stack.py

Testing Stack...

Stack: [12, 13, 14, 15, 16, 17, 18, 19, 20]
Stack size: 9
Stack peek: 20
Stack is empty: False
Stack min: 12

Popping...
20
19
18
17
16
Stack: [12, 13, 14, 15]