From 7c6a425f26e85a52c104ce84411ab3727de830f0 Mon Sep 17 00:00:00 2001 From: Daniel Frederick Crisman Date: Tue, 21 Mar 2023 18:20:43 -0400 Subject: [PATCH] tree: document sorted nature of random trees For the use that the tour makes of "golang.org/x/tour/tree" it is important that the generated trees are sorted. While New() does generate sorted trees it is current documented as "returns a new, random binary tree" and many readers will assume "random" implies "non-sorted". Update doc that trees are "randomly-structured, sorted" to clarify what is random and that trees are sorted. --- tree/tree.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tree/tree.go b/tree/tree.go index 4dfa76cc..b82c28f7 100644 --- a/tree/tree.go +++ b/tree/tree.go @@ -16,7 +16,7 @@ type Tree struct { Right *Tree } -// New returns a new, random binary tree holding the values k, 2k, ..., 10k. +// New returns a new, randomly-structured, sorted binary tree holding the values k, 2k, ..., 10k. func New(k int) *Tree { var t *Tree for _, v := range rand.Perm(10) {