[Tutor] binary trees/ linked lists

Alan Trautman ATrautman@perryjudds.com
Wed, 2 Oct 2002 13:18:38 -0500


Cameron,

The dictionary due to its speed really replaces the linked list. From what
I've seen it handles all the ugly parts for you. 

To make a linked list you need to encapsulate the next (left or right)
object within the root (declare it as a property) and then within each node
as you go. i.e... when you add a new node you instantiate the node and place
it in as a property of the parent object. Until the new node is needed you
instantiate it with a null value allowing all of the normal binary search
tree and list patterns. 

Unfortunately the only good examples of doing this aren't pythonic. Any good
Java objects book will cover this. In addition VB6 and Java pattern books
also apply here. I'm really trying to remember the title of my VB book that
covers this nicely Oh senility sets in early for some of us :)

Hope this helps, did you have anything specific in mind?

Alan

-----Original Message-----
From: Cameron Stoner [mailto:wolf_binary@hotmail.com]
Sent: Wednesday, October 02, 2002 1:09 PM
To: tutor@python.org
Subject: [Tutor] binary trees/ linked lists


Hi folks,

Is there anything like a linked list or binary tree that can be made in 
Python?
Thanks,

Cameron Stoner

_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor