mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-03-04 14:48:45 +00:00
Move bst min to a class
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
from nose.tools import assert_equal
|
||||
|
||||
|
||||
def height(node):
|
||||
if node is None:
|
||||
return 0
|
||||
return 1 + max(height(node.left),
|
||||
height(node.right))
|
||||
|
||||
|
||||
class TestBstMin(object):
|
||||
|
||||
def test_bst_min(self):
|
||||
min_bst = MinBst()
|
||||
array = [0, 1, 2, 3, 4, 5, 6]
|
||||
root = create_min_bst(array)
|
||||
root = min_bst.create_min_bst(array)
|
||||
assert_equal(height(root), 3)
|
||||
|
||||
min_bst = MinBst()
|
||||
array = [0, 1, 2, 3, 4, 5, 6, 7]
|
||||
root = create_min_bst(array)
|
||||
root = min_bst.create_min_bst(array)
|
||||
assert_equal(height(root), 4)
|
||||
|
||||
print('Success: test_bst_min')
|
||||
|
||||
Reference in New Issue
Block a user