forked from ektagarg/go-ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (34 loc) · 850 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
package main
import (
"fmt"
"log"
"time"
bs "./Arrays/Search/binary_search"
ls "./Arrays/Search/linear_search"
bbs "./Arrays/Sort/bubble_sort"
is "./Arrays/Sort/insertion_sort"
ss "./Arrays/Sort/selection_sort"
)
func main() {
a := []int{23, 45, 67, 27, 32, 87, 90, 12}
position := ls.LinearSearch(a, 67)
fmt.Println(position)
b := []int{12, 23, 27, 32, 67, 87, 90}
positions := bs.BinarySearch(b, 67)
fmt.Println(positions)
start := time.Now()
bs := bbs.BubbleSort(a)
elapsed := time.Since(start)
fmt.Println(bs)
log.Printf("bubble took %s", elapsed)
start = time.Now()
is := is.InsertionSort(a)
elapsed = time.Since(start)
fmt.Println(is)
log.Printf("Insertion took %s", elapsed)
start = time.Now()
ss := ss.SelectionSort(a)
elapsed = time.Since(start)
fmt.Println(ss)
log.Printf("Selection took %s", elapsed)
}