private static string Merge(Node root1, Node root2) { // convert to sorted array, merge sort, convert back to tree var array1 = FlattenTree(root1); var array2 = FlattenTree(root2); var mergedArray = MergeArrays(array1, array2); var root = BuildTreeFromArray(mergedArray); return(TreeReader.WriteTree(root)); }
private static void AssertResult(string tree, string expected) { var root = TreeReader.ReadTree(tree); Fix(root); var actual = TreeReader.WriteTree(root); if (actual != expected) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"expected: {expected} actual: {actual}"); Console.ResetColor(); } }