Skip to content
Snippets Groups Projects
Commit 4b7e49fd authored by CSE's avatar CSE
Browse files

Original commit

parents
No related branches found
No related tags found
No related merge requests found
.idea
*.pyc
*.pyo
*.apk
from __future__ import print_function
class Stack(object):
"""
A basic array-based implementation of a stack.
"""
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def is_empty(self):
return self.items == []
class Queue(object):
"""
A basic array-based implementation of a queue.
"""
def __init__(self):
self.items = []
def enqueue(self, item):
self.items.append(item)
def dequeue(self):
return self.items.pop(0)
def is_empty(self):
return self.items == []
class Node(object):
"""
An element in a linked list.
"""
def __init__(self, item=None, next_node=None):
self.item = item
self.next_node = next_node
def __repr__(self):
return repr(self.item)
class LinkedStack(object):
"""
Implement a stack ADT based on a singly linked list.
"""
pass
class LinkedQueue(object):
"""
Implement a queue ADT based on a singly linked list.
"""
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment