Skip to content

Commit

Permalink
Improve print output
Browse files Browse the repository at this point in the history
  • Loading branch information
Leroy Korterink committed Oct 27, 2018
1 parent 1f6425f commit 08c6275
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions BinaryTree/BinaryNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static string ToStringPreOrder(BinaryNode<T> node)
var result = "";

// First Data
result += node.Data;
result += node.Data + " ";

// Then Left
if (node.Left != null)
Expand Down Expand Up @@ -98,7 +98,7 @@ public static string ToStringInOrder(BinaryNode<T> node)
result += ToStringInOrder(node.Left);

// Then Data
result += node.Data;
result += node.Data + " ";

// Then Right
if (node.Right != null)
Expand Down Expand Up @@ -126,7 +126,7 @@ public static string ToStringPostOrder(BinaryNode<T> node)
result += ToStringPostOrder(node.Right);

// Then Data
result += node.Data.ToString();
result += node.Data + " ";

return result;
}
Expand Down
8 changes: 4 additions & 4 deletions BinaryTreeTests/BinaryTreeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ public void Should_PrintPreOrder()
{
var binaryTree = CreateBinaryTree();

Assert.Equal("12453", binaryTree.ToStringPreOrder());
Assert.Equal("1 2 4 5 3 ", binaryTree.ToStringPreOrder());
}

[Fact]
public void Should_PrintInOrder()
{
var binaryTree = CreateBinaryTree();

Assert.Equal("42513", binaryTree.ToStringInOrder());
Assert.Equal("4 2 5 1 3 ", binaryTree.ToStringInOrder());
}

[Fact]
public void Should_PrintPostOrder()
{
var binaryTree = CreateBinaryTree();

Assert.Equal("45231", binaryTree.ToStringPostOrder());
Assert.Equal("4 5 2 3 1 ", binaryTree.ToStringPostOrder());
}

[Fact]
Expand Down Expand Up @@ -108,7 +108,7 @@ public void Should_MergeTrees()

treeOne.Merge(3, treeOne, treeTwo);

Assert.Equal("312", treeOne.ToStringPreOrder());
Assert.Equal("3 1 2 ", treeOne.ToStringPreOrder());

Assert.NotNull(treeOne.GetRoot());
Assert.Null(treeTwo.GetRoot());
Expand Down

0 comments on commit 08c6275

Please sign in to comment.