mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-07 18:08:01 +00:00
Move tree height to a class
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
def height(node):
|
||||
if node is None:
|
||||
return 0
|
||||
return 1 + max(height(node.left),
|
||||
height(node.right))
|
||||
class BstHeight(Bst):
|
||||
|
||||
def height(self, node):
|
||||
if node is None:
|
||||
return 0
|
||||
return 1 + max(self.height(node.left),
|
||||
self.height(node.right))
|
||||
Reference in New Issue
Block a user