mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 14:56:27 -04:00
Add some cool queue, stacks, strings, math, bit manipulation examples (#35)
This commit is contained in:
parent
f3ee2cdf52
commit
0f455a0322
24 changed files with 932 additions and 13 deletions
|
@ -0,0 +1,59 @@
|
|||
## 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]
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue