Logo

Programming-Idioms

History of Idiom 17 > diff from v14 to v15

Edit summary for version 15 by :

Version 14

2015-10-29, 14:05:12

Version 15

2015-10-31, 16:12:25

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to his parent.

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to his parent.

Code
class Node(object):
    def __init__(self, value, *children):
        self.value = value
        self.childern = list(children)