tree data structure

Satchidanand Haridas sharidas at zeomega.com
Sat Mar 26 02:32:02 EST 2005


Hi,

You could use Python dictionaries as trees. Example:

to represent a simple tree:
'a' <- (  'b' ,  'c' )
'b' <- ( 'd',  'e',  'f')
'e' <- ( 'g')
'f' <- ('h', 'i', 'j')

treeD = { 'a' : (
                        { 'b' : (
                                     'd', 
                                    { 'e'  :  'f' },
                                    {f  :  ( 'h', 'i', 'j' )}
                                 )
                        },
                         'c'
                    )
            }

hope this helps.


regards,
Satchit

----
Satchidanand Haridas (sharidas at zeomega dot com)

ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions

#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India



vivek khurana wrote:

>Hi! all
>
>i am a new member on this list. I have to implement 
>tree data structure using python. How it can be done 
>in python. Is there an existing data structure which
>can be used as tree? I have searched archives and 
>manuals but no luck.
>
>Regards
>VK
>
>Hug the REALITY ;-)
>
>
>
>Disclaimer
>The facts expressed here belong to everybody, the opinions to me. The distinction is yours to draw...
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Yahoo! Small Business - Try our new resources site!
>http://smallbusiness.yahoo.com/resources/ 
>  
>



More information about the Python-list mailing list