path = 0 # the lenght of the path
while self.right != None or self.left != None:
while self.right != None:
self = self.right
path = path +1
while self.left != None:
self = self.left
path = path +1
return path
これは、高さを見つけるための私のサンプルコードであり、自己から葉までのノード数による最長パスの長さとして定義されます。リーフノードの高さは1です。
動作しません。