-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_algorithm.go
57 lines (48 loc) · 1.22 KB
/
test_algorithm.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
package main
import (
"fmt"
"mygithub/go-algorithms/algorithm/sorting"
)
func TestAlgorithm() {
BubbleSortTest()
HeapSortTest()
InsertionSortTest()
MergeSortTest()
QuickSortTest()
SelectionSortTest()
}
func BubbleSortTest() {
arr := []int{6, 3, 5, 3, 1, 10, 9, 4, 8, 6}
fmt.Println("Unsorted >> ", arr)
sorting.Bubble(arr)
fmt.Println("Bubble sorted >> ", arr)
}
func HeapSortTest() {
arr := []int{6, 3, 5, 3, 1, 10, 9, 4, 8, 6}
fmt.Println("Unsorted >> ", arr)
sorting.HeapSort(arr)
fmt.Println("Heap sorted >> ", arr)
}
func InsertionSortTest() {
arr := []int{6, 3, 5, 3, 1, 10, 9, 4, 8, 6}
fmt.Println("Unsorted >> ", arr)
sorting.Insertion(arr)
fmt.Println("Insertion sorted >> ", arr)
}
func MergeSortTest() {
arr := []int{6, 3, 5, 3, 1, 10, 9, 4, 8, 6}
fmt.Println("Unsorted >> ", arr)
fmt.Println("Mergesorted >> ", sorting.MergeSort(arr))
}
func QuickSortTest() {
arr := []int{6, 3, 5, 3, 1, 10, 9, 4, 8, 6}
fmt.Println("Unsorted >> ", arr)
//QuickSort(arr)
fmt.Println("Quicksorted >> ", sorting.QuickSort(arr))
}
func SelectionSortTest() {
arr := []int{6, 3, 5, 3, 1, 10, 9, 4, 8, 6}
fmt.Println("Unsorted >> ", arr)
sorting.Selection(arr)
fmt.Println("Selection sorted >> ", arr)
}