MCPcopy Create free account
hub / github.com/careercup/ctci / New

Function New

go/chapter04/binarytree/binarytree.go:77–83  ·  view source on GitHub ↗

New returns a new, random binary tree holding the values 1k, 2k, ..., nk.

(n, k int)

Source from the content-addressed store, hash-verified

75// New returns a new, random binary tree
76// holding the values 1k, 2k, ..., nk.
77func New(n, k int) *Tree {
78 var t *Tree
79 for _, v := range rand.Perm(n) {
80 t = insert(t, (1+v)*k)
81 }
82 return t
83}
84
85// New returns a new, empty binary tree
86func NewTree() *Tree {

Callers

nothing calls this directly

Calls 1

insertFunction · 0.85

Tested by

no test coverage detected