forked from nryoung/algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.py
More file actions
27 lines (23 loc) · 650 Bytes
/
Copy pathstack.py
File metadata and controls
27 lines (23 loc) · 650 Bytes
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
"""
Stack data structure implemented:
--------------------------------
add : add element at last
remove : remove element from last
return value
is_empty : 1 value returned on empty
0 value returned on not empty
size : return size of stack
Time Complexity: O(1)
"""
class stack :
stack_list = []
def __init__(self):
self.stack_list = []
def add(self,value):
self.stack_list.append(value)
def remove(self):
return self.stack_list.pop()
def is_empty(self):
return not len(self.stack_list)
def size(self):
return len(self.stack_list)