-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathStack.py
63 lines (39 loc) · 1.1 KB
/
Stack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#Stack design using LIST
'''
l = [eval(x) for x in input("Enter elements onto stack: ").split(",")]
print('Initial stack')
print(l)
print('Elements poped from stack:')
print(l.pop())
print(l.pop())
print(l.pop())
print('Stack after elements are poped:')
print(l)
'''
#Stack design using DEQUE
'''
from collections import deque
stack = deque([eval(x) for x in input("Enter elements onto stack: ").split(",")])
print('Initial stack:')
print(stack)
print('Elements poped from stack:')
print(stack.pop())
print(stack.pop())
print(stack.pop())
print('Stack after elements are poped:')
print(stack)
'''
# Stack design using LIFOQUEUE
from queue import LifoQueue
lifostack = LifoQueue(maxsize = 5)
print(lifostack.qsize())
lifostack.put('sugar')
lifostack.put('lemon drops')
lifostack.put('water')
print("Full: ", lifostack.full())
print("Size: ", lifostack.qsize())
print('Elements poped from the stack')
print(lifostack.get())
print(lifostack.get())
print(lifostack.get())
print("Empty: ", lifostack.empty())