In the concurrency section of Golang tour there is an exercise as follows. The problem statement wants to verify that two input trees are as the same or not.
The problem here is when we changing the traversal order from in-order to pre/post-order it fails. i.e the bellow code works correctly
if t != nil {
traverse(t.Left, ch)
ch <- t.Value
traverse(t.Right, ch)
}
but if we first put the value to channel and then went to node's children its answer became wrong(run this and this for same input which output is difference).
Since we used the same code for traversing its expected that the order should not matter(i.e values goes to the channel in the same order...).
PS: You can find more answers to this exercise here.