-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (50 loc) · 995 Bytes
/
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
package main
import (
"fmt"
"github.com/paichana/algorithms/btree"
"github.com/paichana/algorithms/linkedlist"
"github.com/paichana/algorithms/queue"
)
func main() {
n1 := btree.New("1")
n2 := btree.New("2")
n3 := btree.New("3")
n4 := btree.New("4")
n5 := btree.New("5")
n6 := btree.New("6")
n7 := btree.New("7")
n8 := btree.New("8")
n1.AddLeft(n2)
n1.AddRight(n3)
n2.AddLeft(n4)
n2.AddRight(n5)
n3.AddLeft(n6)
n3.AddRight(n7)
n4.AddLeft(n8)
fmt.Println("DFS")
btree.DFS(n1)
fmt.Println("DFS recursive")
btree.DFSRecursive(n1)
fmt.Println("BFS")
btree.BFS(n1)
q := queue.New()
q.Push("1")
q.Push("2")
q.Push("3")
q.Push("4")
q.Push("5")
q.Push("6")
fmt.Println(q.Pop().(string))
fmt.Println(q.Pop().(string))
fmt.Println(q.Pop().(string))
q.Push("7")
q.Print()
ll := linkedlist.New()
ll.AddBack("1")
ll.AddBack("2")
ll.AddFront("0")
ll.AddFront("-1")
ll.Print()
fmt.Println(ll.GetBack().(string))
fmt.Println(ll.GetFront().(string))
}