forked from bloominstituteoftechnology/Graphs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2b6a80
commit 6f7e8b1
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
# Note: This Queue class is sub-optimal. Why? | ||
class Queue(): | ||
def __init__(self): | ||
self.queue = [] | ||
def enqueue(self, value): | ||
self.queue.append(value) | ||
def dequeue(self): | ||
if self.size() > 0: | ||
return self.queue.pop(0) | ||
else: | ||
return None | ||
def size(self): | ||
return len(self.queue) | ||
|
||
class Stack(): | ||
def __init__(self): | ||
self.stack = [] | ||
def push(self, value): | ||
self.stack.append(value) | ||
def pop(self): | ||
if self.size() > 0: | ||
return self.stack.pop() | ||
else: | ||
return None | ||
def size(self): | ||
return len(self.stack) | ||
|