Exercise: Equivalent Binary Trees in Golang
1 min readMay 15, 2021
From Tour of Go
package mainimport "golang.org/x/tour/tree"
import "fmt"// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
if t == nil {
return
}if t.Left != nil {
Walk(t.Left, ch)
}ch <- t.Valueif t.Right != nil {
Walk(t.Right, ch)
}
}// Same determines whether the trees
// t1 and t2 contain the same values.
func…