ZahirJS commited on
Commit
8845dfd
·
verified ·
1 Parent(s): 6c2a865

Update binary_tree_generator.py

Browse files
Files changed (1) hide show
  1. binary_tree_generator.py +127 -15
binary_tree_generator.py CHANGED
@@ -18,36 +18,148 @@ def generate_binary_tree_diagram(json_input: str, output_format: str) -> str:
18
  {
19
  "root": {
20
  "id": "root",
21
- "label": "50",
22
  "left": {
23
- "id": "left_1",
24
- "label": "30",
25
  "left": {
26
- "id": "left_2",
27
- "label": "20"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  },
29
  "right": {
30
- "id": "right_2",
31
- "label": "40"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
  },
34
  "right": {
35
- "id": "right_1",
36
- "label": "70",
37
  "left": {
38
- "id": "left_3",
39
- "label": "60"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  },
41
  "right": {
42
- "id": "right_3",
43
- "label": "80"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
  }
46
  }
47
  }
48
-
49
  Returns:
50
- str: The filepath to the generated PNG image file.
51
  """
52
  try:
53
  if not json_input.strip():
 
18
  {
19
  "root": {
20
  "id": "root",
21
+ "label": "80",
22
  "left": {
23
+ "id": "node_35",
24
+ "label": "35",
25
  "left": {
26
+ "id": "node_12",
27
+ "label": "12",
28
+ "left": {
29
+ "id": "node_8",
30
+ "label": "8",
31
+ "right": {
32
+ "id": "node_10",
33
+ "label": "10"
34
+ }
35
+ },
36
+ "right": {
37
+ "id": "node_28",
38
+ "label": "28",
39
+ "left": {
40
+ "id": "node_15",
41
+ "label": "15",
42
+ "right": {
43
+ "id": "node_22",
44
+ "label": "22",
45
+ "left": {
46
+ "id": "node_18",
47
+ "label": "18"
48
+ },
49
+ "right": {
50
+ "id": "node_25",
51
+ "label": "25"
52
+ }
53
+ }
54
+ },
55
+ "right": {
56
+ "id": "node_32",
57
+ "label": "32",
58
+ "left": {
59
+ "id": "node_30",
60
+ "label": "30"
61
+ }
62
+ }
63
+ }
64
  },
65
  "right": {
66
+ "id": "node_65",
67
+ "label": "65",
68
+ "right": {
69
+ "id": "node_72",
70
+ "label": "72",
71
+ "left": {
72
+ "id": "node_68",
73
+ "label": "68"
74
+ },
75
+ "right": {
76
+ "id": "node_76",
77
+ "label": "76",
78
+ "right": {
79
+ "id": "node_78",
80
+ "label": "78"
81
+ }
82
+ }
83
+ }
84
  }
85
  },
86
  "right": {
87
+ "id": "node_120",
88
+ "label": "120",
89
  "left": {
90
+ "id": "node_95",
91
+ "label": "95",
92
+ "left": {
93
+ "id": "node_88",
94
+ "label": "88",
95
+ "left": {
96
+ "id": "node_85",
97
+ "label": "85"
98
+ },
99
+ "right": {
100
+ "id": "node_92",
101
+ "label": "92"
102
+ }
103
+ },
104
+ "right": {
105
+ "id": "node_110",
106
+ "label": "110",
107
+ "left": {
108
+ "id": "node_105",
109
+ "label": "105",
110
+ "right": {
111
+ "id": "node_108",
112
+ "label": "108"
113
+ }
114
+ }
115
+ }
116
  },
117
  "right": {
118
+ "id": "node_180",
119
+ "label": "180",
120
+ "left": {
121
+ "id": "node_140",
122
+ "label": "140",
123
+ "right": {
124
+ "id": "node_165",
125
+ "label": "165",
126
+ "left": {
127
+ "id": "node_155",
128
+ "label": "155"
129
+ },
130
+ "right": {
131
+ "id": "node_170",
132
+ "label": "170",
133
+ "right": {
134
+ "id": "node_175",
135
+ "label": "175"
136
+ }
137
+ }
138
+ }
139
+ },
140
+ "right": {
141
+ "id": "node_220",
142
+ "label": "220",
143
+ "left": {
144
+ "id": "node_200",
145
+ "label": "200",
146
+ "left": {
147
+ "id": "node_190",
148
+ "label": "190"
149
+ },
150
+ "right": {
151
+ "id": "node_210",
152
+ "label": "210"
153
+ }
154
+ }
155
+ }
156
  }
157
  }
158
  }
159
  }
160
+
161
  Returns:
162
+ str: The filepath to the generated image file.
163
  """
164
  try:
165
  if not json_input.strip():