1
2
3
4
5
6
7
8
9
10
11
12
|
import pdb
class Tree():
def __init__(self):
self.nodes = []
def traverse_depth_first(self):
all_nodes = []
for node in self.nodes:
if isinstance(node, Node):
all_nodes.append(node)
elif isinstance(node, Tree):
|
|
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import pdb
class Tree():
def __init__(self, name):
self.nodes = []
self.name = name
def traverse_depth_first(self):
all_nodes = []
for node in self.nodes:
if isinstance(node, Node):
all_nodes.append(node)
elif isinstance(node, Tree):
|