Exemplo n.º 1
0
        public static void Test()
        {
            BiNode root = createTree();

            printAsTree(root, "");
            NodePair n = convert(root);

            printLinkedListTree(n.head);
        }
Exemplo n.º 2
0
        public static NodePair convert(BiNode root)
        {
            if (root == null)
            {
                return(null);
            }

            NodePair part1 = convert(root.node1);
            NodePair part2 = convert(root.node2);

            if (part1 != null)
            {
                concat(part1.tail, root);
            }

            if (part2 != null)
            {
                concat(root, part2.head);
            }

            return(new NodePair(part1 == null ? root : part1.head, part2 == null ? root : part2.tail));
        }