Skip to content

Commit f770a00

Browse files
committed
unit6 pro4 solved
1 parent 75ce399 commit f770a00

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

unit6/.pro4.py.swp

12 KB
Binary file not shown.

unit6/pro4.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from opus7.tree import Tree
2+
3+
class treeCompare(Tree):
4+
5+
def _compareTo(self, obj):
6+
assert isInstance(self, obj.__class__)
7+
if self.isEmpty:
8+
if obj.isEmpty:
9+
return 0
10+
else:
11+
return -1
12+
elif obj.isEmpty:
13+
return 1
14+
else:
15+
result = cmp(self._key, obj._key)
16+
i = 0
17+
while result == 0 and i < self.degree:
18+
result = cmp(self.getSubtree(i), obj.getSubtree(i))
19+
i += 1
20+
return result
21+

0 commit comments

Comments
 (0)