MCPcopy Index your code
hub / github.com/0xAX/go-algorithms / Insert

Method Insert

binaryTree/binaryTree.go:34–46  ·  view source on GitHub ↗
(value interface{})

Source from the content-addressed store, hash-verified

32}
33
34func (tree *BinaryTree) Insert(value interface{}) {
35 if tree.node == nil {
36 tree.node = value
37 tree.right = New(tree.lessFun)
38 tree.left = New(tree.lessFun)
39 return
40 }
41 if tree.lessFun(value, tree.node) {
42 tree.left.Insert(value)
43 } else {
44 tree.right.Insert(value)
45 }
46}
47
48func (tree *BinaryTree) Max() interface{} {
49 if tree.node == nil || tree.right.node == nil {

Callers 2

Test_binaryTreeFunction · 0.80
Test_minmaxFunction · 0.80

Calls 1

NewFunction · 0.70

Tested by 2

Test_binaryTreeFunction · 0.64
Test_minmaxFunction · 0.64