[Tutor] Nodes and Queues?
Patrick Sabin
patrick.just4fun at gmail.com
Wed May 11 14:14:03 CEST 2011
A queue is a data structure, which keeps track of multiple objects. You
can add data to a queue or you can remove it. When you remove an object
from a queue you get the element which you have added first. Therefore,
it is also called FIFO (First In First Out). A basic implementation
could look like this:
class Queue:
def __init__(self):
self.items = []
def add(self, obj):
self.items.append(obj)
def remove(self):
self.items.pop(0)
Nodes are used in multiple contexts, but usually refer to objects which
have child objects.
--
Patrick
On 2011-05-11 13:44, Clara Mintz wrote:
>
> Hi all
> I am sorry I am a beginner at python and I was reading my book and I came across the terms Nodes and Queue. I am sorry but I don't quite understand how they work. Is there anyone who could possibly explain them in simple terms? Thank you so much.
> Sincerely,
> Clara
More information about the Tutor
mailing list