-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
86 lines (67 loc) · 1.34 KB
/
main.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"fmt"
"mygithub/go-algorithms/datastructures/stack"
"mygithub/go-algorithms/datastructures/queue"
"mygithub/go-algorithms/datastructures/bintree"
//"mygithub/go-algorithms/datastructures/heap"
)
func main() {
//stackTest()
//queueTest()
//bintreeTest()
//bintreesTest()
//heapTest()
TestAlgorithm()
}
func stackTest() {
s := stack.NewStackS()
s.Push("m")
fmt.Println(s)
}
func queueTest() {
q := queue.NewQueue()
fmt.Println(q)
}
func bintreeTest() {
b := bintree.NewBintree()
b.Insert("m")
b.Insert("b")
b.Insert("a")
b.Insert("c")
b.Insert("o")
b.Insert("n")
b.Insert("z")
b.Remove("c")
fmt.Println(b)
fmt.Println(b.Search("d"))
fmt.Println("\nPreorder >> ")
b.Traverse(bintree.Pre, func (n *bintree.Node) { fmt.Print(n) })
fmt.Println("\nInorder >> ")
b.Traverse(bintree.In, func (n *bintree.Node) { fmt.Print(n) })
fmt.Println("\nPostorder >> ")
b.Traverse(bintree.Post, func (n *bintree.Node) { fmt.Print(n) })
}
func bintreesTest() {
b := bintree.NewBintreeS()
fmt.Println(b)
b.Insert("m")
b.Insert("b")
b.Insert("a")
b.Insert("c")
b.Insert("o")
b.Insert("n")
b.Insert("z")
fmt.Println(b.Children("b"))
fmt.Println(b)
b.Remove("c")
fmt.Println(b)
fmt.Println(b.Search("a"))
fmt.Println(b.Get(2))
}
/*
func heapTest() {
h := heap.NewHeap()
fmt.Println(h)
}
*/