Stack
Common Operations
Advantages
Disadvantages
Real-Life Applications
Implementation
class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return len(self.items) == 0
def push(self, item):
self.items.append(item)
def pop(self):
if self.is_empty():
return None
return self.items.pop()
def peek(self):
if self.is_empty():
return None
return self.items[-1]
def size(self):
return len(self.items)
More code implementations (in all of your favourite languages - Java, C++, Swift) can be found here.
That's a wrap. Get subscribed if you aren't already. Come back tomorrow for more.
If you found this useful, share it with your friends.