Lecture Notes on 22 Feb 2017 Read Chapter 2: Algorithm Analysis class Stack (object): def __init__ (self): self.stack = [] # add an item to the top of the stack def push (self, item): self.stack.append (item) # remove an item from the top of the stack def pop (self): return self.stack.pop() # check what an item is on the top of the stack def peek (self): return self.stack[-1] # check if stack is empty def isEmpty (self): return (len(self.stack) == 0) # return the number of elements in the stack def size (self): return (len(self.stack))