Open phluks opened 5 years ago
The Walker need to use Inorder traversal (Left, Root, Right) to generate 1, 2, 3, ... 10.
func Walker(t *tree.Tree, ch chan int) {
if t != nil {
if t.Left != nil {
Walker(t.Left, ch)
}
ch <- t.Value
if t.Right != nil {
Walker(t.Right, ch)
}
}
}
This code shows that calling tree.New(1) creates different trees on consecutive calls
Isn't that the idea of the example? All created trees contain the same values but they are balanced differently. A pure "deep equal test" (that you can easily implement in a synchronous manner) will not suffice, but you need to walk the trees in parallel.
Context: https://tour.golang.org/concurrency/8
Hi golang.
I'm not sure if it is on purpose or a bug, but it is quite confusing. If it is on purpose, I'd say it's not helpful.
Anyway, feel free to close the issue at your own discretion.
This code shows that calling tree.New(1) creates different trees on consecutive calls