class ListStack: def __init__(self): self._data = LinkedList() def push(self, value): self._data.insertAtHead(value) def pop(self): return self._data.pop_head() def is_empty(self): return (self._data.size() == 0) def peek(self): return self._data._head.get_value()
class ListQueue: def __init__(self): self._data = LinkedList() def enqueue(self, value): self._data.insertAtTail(value) def dequeue(self): return self._data.pop_head() def is_empty(self): return (self._data.size() == 0) def size(self): self._data.size()
def __init__(self): self._data = LinkedList()