forked from TheAlgorithms/Go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinarysearchtree.go
More file actions
38 lines (34 loc) · 844 Bytes
/
Copy pathbinarysearchtree.go
File metadata and controls
38 lines (34 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Binary search tree
// https://en.wikipedia.org/wiki/Binary_search_tree
package binarytree
// import (
// "fmt"
// )
// func main() {
// t := &BTree{nil}
// InOrder(t.root)
// t.root = Insert(t.root, 30)
// t.root = Insert(t.root, 20)
// t.root = Insert(t.root, 15)
// t.root = Insert(t.root, 10)
// t.root = Insert(t.root, 12)
// t.root = Insert(t.root, 9)
// t.root = Insert(t.root, 11)
// t.root = Insert(t.root, 17)
// fmt.Print(t.depth(), "\n")
// InOrder(t.root)
// fmt.Print("\n")
// t.root = BstDelete(t.root, 10)
// InOrder(t.root)
// fmt.Print("\n")
// t.root = BstDelete(t.root, 30)
// InOrder(t.root)
// fmt.Print("\n")
// t.root = BstDelete(t.root, 15)
// InOrder(t.root)
// fmt.Print("\n")
// t.root = BstDelete(t.root, 20)
// InOrder(t.root)
// fmt.Print("\n")
// fmt.Print(t.depth(), "\n")
// }