mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 02:48:02 +00:00
Added binary tree balance check challenge.
This commit is contained in:
30
graphs_trees/check_balance/test_check_balance.py
Normal file
30
graphs_trees/check_balance/test_check_balance.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from nose.tools import assert_equal
|
||||
|
||||
|
||||
class TestCheckBalance(object):
|
||||
|
||||
def test_check_balance(self):
|
||||
node = Node(5)
|
||||
insert(node, 3)
|
||||
insert(node, 8)
|
||||
insert(node, 1)
|
||||
insert(node, 4)
|
||||
assert_equal(check_balance(node), True)
|
||||
|
||||
node = Node(5)
|
||||
insert(node, 3)
|
||||
insert(node, 8)
|
||||
insert(node, 9)
|
||||
insert(node, 10)
|
||||
assert_equal(check_balance(node), False)
|
||||
|
||||
print('Success: test_check_balance')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestCheckBalance()
|
||||
test.test_check_balance()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user