Renamed top-level folders to use underscores instead of dashes.

This commit is contained in:
Donne Martin
2015-06-28 06:39:24 -04:00
parent d44ed31ef9
commit 7573730e39
53 changed files with 0 additions and 0 deletions

29
stacks_queues/stack.py Normal file
View File

@@ -0,0 +1,29 @@
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class Stack(object):
def __init__(self, top=None):
self.top = top
def push(self, data):
node = Node(data)
node.next = self.top
self.top = node
def pop(self):
if self.top is not None:
data = self.top.data
self.top = self.top.next
return data
return None
def peek(self):
if self.top is not None:
return self.top.data
return None
def is_empty(self):
return self.peek() is None