def __init__(self): super(ConstructBiTreePreInOrderTestCases, self).__init__() self.__add_test_case__( 'test 1', ([5, 3, 1, 2, 4, 8, 9], [1, 2, 3, 4, 5, 8, 9]), to_complete_binary_tree([5, 3, 8, 1, 4, None, 9, None, 2])) self.__add_test_case__('test 2', ([-1], [-1]), to_complete_binary_tree([-1]))
def __init__(self): super(BstIterTestCases, self).__init__() self.__add_test_case__( 'Test 1', to_complete_binary_tree([5, 2, 6, 1, 3, None, 7]), [1, 2, 3, 5, 6, 7]) self.__add_test_case__('Test 2', to_complete_binary_tree([3, 1, 4, None, 2]), [1, 2, 3, 4]) self.__add_test_case__('Test 3', None, [])
def __init__(self): super(BitreeZigzagTestCases, self).__init__() self.__add_test_case__( 'Test 1', to_complete_binary_tree([1, None, 2, None, None, 3, None]), [[1], [2], [3]]) self.__add_test_case__( 'Test 2', to_complete_binary_tree([1, 2, 3, 4, 5, None, 6]), [[1], [3, 2], [4, 5, 6]]) self.__add_test_case__('Test 3', None, [])
def __init__(self): super(ConstructBiTreeInPostOrderTestCases, self).__init__() self.__add_test_case__( 'test 1', ([1, 2, 3, 4, 5, 8, 9], [2, 1, 4, 3, 9, 8, 5]), to_complete_binary_tree([5, 3, 8, 1, 4, None, 9, None, 2])) self.__add_test_case__('test 2', ([-1], [-1]), to_complete_binary_tree([-1])) self.__add_test_case__( 'test 3', ([1, 3, 2], [3, 2, 1]), to_complete_binary_tree([1, None, 2, None, None, 3]))
def __init__(self): super(BitreePreOrderTestCases, self).__init__() self.__add_test_case__( 'Test 1', to_complete_binary_tree([1, None, 2, None, None, 3, None]), [1, 2, 3]) self.__add_test_case__( 'Test 2', to_complete_binary_tree([1, 2, 3, 4, 5, None, 6]), [1, 2, 4, 5, 3, 6]) self.__add_test_case__('Test 3', None, [])
def __init__(self): super(DeSerialBstTestCases, self).__init__() tree = to_complete_binary_tree([5, 3, 8, 1, 4, None, 9, None, 2]) data = '5 3 1 n 2 n n 4 n n 8 n 9 n n' self.__add_test_case__('test 1', (tree, data), (data, tree))
def __init__(self): super(BiTreePostOrderTestCases, self).__init__() self.__add_test_case__('Test 1', to_complete_binary_tree([1, None, 2, None, None, 3, None]), [3, 2, 1]) self.__add_test_case__('Test 2', to_complete_binary_tree([1, 2, 3, 4, 5, None, 6]), [4, 5, 2, 6, 3, 1]) self.__add_test_case__('Test 3', None, [])
def __get_tree_one__(self): input = [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, None, 5, 1] return l2t.to_complete_binary_tree(input)
def __init__(self): super(MaxBiTreeDepthTestCases, self).__init__() self.__add_test_case__( "Test 1", to_complete_binary_tree([1, 2, 3, 4, 5, None, 7, 8]), 4) self.__add_test_case__("Test 2", to_complete_binary_tree([1, 2, 3]), 2)