mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-30 04:36:08 -04:00
59 lines
765 B
Markdown
59 lines
765 B
Markdown
## stacks and queues
|
|
|
|
<br>
|
|
|
|
### `Queues.py`
|
|
|
|
<br>
|
|
|
|
```python
|
|
> 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)]
|
|
```
|
|
|
|
<br>
|
|
|
|
### `stack.py`
|
|
|
|
<br>
|
|
|
|
```python
|
|
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]
|
|
``` |