[Tutor] confused by linked queue
Christopher Spears
cspears2002 at yahoo.com
Tue Jul 25 07:55:17 CEST 2006
After reading John's reply, I think I get it now:
>>> from linked_queue import *
>>> queue = Queue()
>>> queue.isEmpty()
True
>>> queue.insert("cargo")
>>> queue.length
1
>>> queue.insert("more cargo")
>>> queue.length
2
>>> print queue.head
cargo
>>> print queue.head.next
more cargo
>>> queue.insert("more and better cargo")
>>> print queue.head.next
more cargo
>>> print queue.head.next.next
more and better cargo
>>> queue.insert("snakes")
>>> print queue.head
cargo
>>> last = queue.head
>>> last.next
<linked_queue.Node instance at 0xb7d5fdcc>
>>> print last.next
more cargo
>>> print last.next.next
more and better cargo
>>> print last.next.next.next
snakes
One of my problems in conecptualizing this is that I
thought a linked queue was just a linked list. Is a
linked queue a linked list? There seems to be a
subtle difference...
More information about the Tutor
mailing list