stack - class Queue: def __init__(self) : self.queue = def...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Here are definitions of stack and queue structures in Python class Stack: def __init__(self) : self.stack = [] def push(self, object) : self.stack.append(object) def pop(self) : tmp = self.stack[-1] del self.stack[-1] return tmp def size(self) : return len(self.stack)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: class Queue: def __init__(self) : self.queue = def enqueue(self, object) : self.queue.append(object) def dequeue(self) : tmp = self.queue[0] del self.queue[0] return tmp def size(self) : return len(self.queue)...
View Full Document

This note was uploaded on 03/07/2010 for the course CS 6913 taught by Professor Torsensuel during the Spring '10 term at NYU Poly.

Ask a homework question - tutors are online