| Store | Cart

tree data structure

From: Dan Bishop <danb...@yahoo.com>
25 Mar 2005 23:12:05 -0800
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?

Tuples can be used as trees: you can let them represent (data,
left_child, right_child).

# a binary search tree for the integers 0 to 6
(3, (1, (0, None, None),
        (2, None, None)),
    (4, (5, None, None),
        (6, None, None)))

Recent Messages in this Thread
Dan Bishop Mar 26, 2005 07:12 am