def test_prev_node_of_min(self): """ test the following binary search tree 1 \ 2 \ 3 <-- get next node of 3 """ bst = BinarySearchTree() bst.insert(1) bst.insert(2) node = bst.insert(3) self.assertEqual(bst.next(node), None)
def test_next_node_has_right_subtree(self): """ test the following binary search tree 1 <-- get next node of 1 \ 3 / \ 2 4 """ bst = BinarySearchTree() node = bst.insert(1) bst.insert(3) expected_next = bst.insert(2) bst.insert(4) self.assertEqual(bst.next(node), expected_next)