We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0888074 commit 9b93c80Copy full SHA for 9b93c80
general_tree_structure.py
@@ -0,0 +1,21 @@
1
+class Node:
2
+ def __init__(self, value=None, children=[]):
3
+ self.value = value
4
+ self.children = children
5
+
6
+ def getValue(self):
7
+ return self.value
8
9
+ def setValue(self, new_value):
10
+ self.value = new_value
11
12
+ def getNumChildren(self):
13
+ return len(self.children)
14
15
+ def getChild(self, index):
16
+ return self.children[index]
17
18
+root = Node(5,[Node(2), Node(6)])
19
+print(root.getValue()) # 5
20
+print(root.getNumChildren()) # 2
21
+print(root.getChild(1)) # <Node object at 0x7f856fe764e0>
0 commit comments