Exercise: Equivalent Binary Trees

There can be many different binary trees with the same sequence of values stored in it. For example, here are two binary trees storing the sequence 1, 1, 2, 3, 5, 8, 13.Exercise: Equivalent Binary Trees - 图1 A function to check whether two binary trees store the same sequence is quite complex in most languages. We'll use Go's concurrency and channels to write a simple solution.

This example uses the tree package, which defines the type:

  1. type Tree struct {
  2. Left *Tree
  3. Value int
  4. Right *Tree
  5. }

Continue description on next page).