Skip to content

Commit 75ce399

Browse files
committed
unit6 pro3 solved
1 parent a070536 commit 75ce399

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

unit6/pro3.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from opus7.tree import Tree
2+
3+
class treeLeafCount(Tree):
4+
5+
def getLeafCount(self):
6+
if self.isEmpty:
7+
return 0
8+
result = 0
9+
for i in xrange(self.degree):
10+
if self.getSubtree(i).isLeaf:
11+
result += 1
12+
else:
13+
result += self.getSubtree(i).leafCount
14+
return result

0 commit comments

Comments
 (0)