// Root{left, right}: {1{2{3, 4}, 2{4, 3}}} // PreOrder: {1, 2, 3, 4, 2, 4, 3} // MirrorPreOrder: {1, 2, 3, 4, 2, 4, 3} // InOrder: {3, 2, 4, 1, 4, 2, 3} // MirrorInOrder: {3, 2, 4, 1, 4, 2, 3} // PostOrder: {3, 4, 2, 4, 3, 2, 1} // MirrorPostOrder: {3, 4, 2, 4, 3, 2, 1} public static BinaryTree.TreeNode testTree_symmetric() { BinaryTree.TreeNode root = new BinaryTree.TreeNode(1); root.left = new BinaryTree.TreeNode(2); root.right = new BinaryTree.TreeNode(2); root.left.left = new BinaryTree.TreeNode(3); root.left.right = new BinaryTree.TreeNode(4); root.right.left = new BinaryTree.TreeNode(4); root.right.right = new BinaryTree.TreeNode(3); return(root); }
// Root{left, right}: {1{2{4{,8}, 5}, 3{6{9, 10}, 7{11, 12}}}} // PreOrder: {1, 2, 4, 8, 5, 3, 6, 9, 10, 7, 11, 12} // InOrder: {4, 8, 2, 5, 1, 9, 6, 10, 3, 11, 7, 12} // PostOrder: {8, 4, 5, 2, 9, 10, 6, 11, 12, 7, 3, 1} // LevelOrder: {{1}, {2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11, 12}} public static BinaryTree.TreeNode testTree1() { int currentVal = 1; BinaryTree.TreeNode root = new BinaryTree.TreeNode(currentVal++); root.left = new BinaryTree.TreeNode(currentVal++); root.right = new BinaryTree.TreeNode(currentVal++); root.left.left = new BinaryTree.TreeNode(currentVal++); root.left.right = new BinaryTree.TreeNode(currentVal++); root.right.left = new BinaryTree.TreeNode(currentVal++); root.right.right = new BinaryTree.TreeNode(currentVal++); root.left.left.right = new BinaryTree.TreeNode(currentVal++); root.right.left.left = new BinaryTree.TreeNode(currentVal++); root.right.left.right = new BinaryTree.TreeNode(currentVal++); root.right.right.left = new BinaryTree.TreeNode(currentVal++); root.right.right.right = new BinaryTree.TreeNode(currentVal++); return(root); }