Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 8bbc62b

Browse files
committed
XD
1 parent 34c410d commit 8bbc62b

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

Node.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import collections
2+
from graphical import drawtree , deserialize
23

34
NodesBeenMade = 0
45

@@ -100,8 +101,35 @@ def find(self , atribute) :
100101
for j in i :
101102
if j == atribute :
102103
return x
104+
105+
def MakeList(self , type ) -> list :
106+
MyList = []
107+
result = tree.PrintTree(type)
108+
for i in result :
109+
if i != "," :
110+
MyList.append(int(i))
111+
return MyList
112+
113+
def compare(self , type ) :
114+
result = tree.MakeList(type)
115+
print(result)
116+
lst = list(map(int , input('Enter your tree with desired order : ').split()))
117+
return True if result == lst else False
118+
119+
def draw(self) :
120+
result = tree.PrintTree('levelorder')
121+
result_fixed = []
122+
for i in result :
123+
for j in i :
124+
result_fixed.append(j)
125+
drawtree(deserialize(str(result_fixed)))
126+
127+
103128

104129

130+
131+
132+
105133

106134

107135
"""_summary_
@@ -124,7 +152,7 @@ def find(self , atribute) :
124152
# delete the tree -> 1
125153
# MAX and MIN in our tree -> 1
126154
# full tree -> 0
127-
# compare of two tree -> 0
155+
# compare of two tree -> 1
128156

129157

130158

@@ -137,8 +165,13 @@ def find(self , atribute) :
137165

138166

139167

140-
print(tree.PrintTree("levelorder"))
141-
result = tree.MAX_MIN()
142-
print("MAX and MIN is equal to : " , result)
143-
x = tree.find(5)
144-
print("Found the desired element at the : [" , x , "] floor ")
168+
# print(tree.PrintTree("preorder"))
169+
# result = tree.MAX_MIN()
170+
# print("MAX and MIN is equal to : " , result)
171+
# x = tree.find(5)
172+
# print("Found the desired element at the : [" , x , "] floor ")
173+
print(tree.draw())
174+
175+
# lst = list(map(int , input('Enter your tree with ' , type , " order : ").split()))
176+
# print(lst)
177+
2.16 KB
Binary file not shown.

graphical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def draw(node, x, y, dx):
4444
turtle.mainloop()
4545

4646
if __name__ == '__main__':
47-
drawtree(deserialize('[2,5,1,7,2,3,4,5,9]'))
47+
drawtree(deserialize('[2,3,4,5,6]'))
4848

4949

5050

0 commit comments

Comments
 (0)