| // Copyright 2011 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // A Tree is a binary tree with integer values. |
| // New returns a new, random binary tree holding the values k, 2k, ..., 10k. |
| for _, v := range rand.Perm(10) { |
| func insert(t *Tree, v int) *Tree { |
| return &Tree{nil, v, nil} |
| t.Left = insert(t.Left, v) |
| t.Right = insert(t.Right, v) |
| func (t *Tree) String() string { |
| s += t.Left.String() + " " |
| s += " " + t.Right.String() |