-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalgo_test.go
72 lines (48 loc) · 1.09 KB
/
algo_test.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
package goist
import "fmt"
func ExampleBinarySearch() {
nums := []int{22, 11, 33, 100}
target1 := 1
target2 := 11
i1 := BinarySearch(nums, target1)
i2 := BinarySearch(nums, target2)
fmt.Println(i1, i2)
// Output: false true
}
func ExampleClimbStairs3() {
n := ClimbStairs3(22)
fmt.Println(n)
// Output: 410744
}
func ExampleFibonacciRecursion() {
n1 := FibonacciRecursion(22)
n2 := FibonacciDP(22)
fmt.Println(n1, n1 == n2)
// Output: 17711 true
}
func ExampleBubbleSort() {
nums := []int{22, 11, 33, 55, 44, 66}
nums2 := BubbleSort(nums)
fmt.Println(nums2)
// Output: [11 22 33 44 55 66]
}
func ExampleBucketSort() {
nums := []int{22, 11, 33, 55, 44, 66, 7}
nums2 := BucketSort(nums, 2)
fmt.Println(nums2)
// Output: [7 11 22 33 44 55 66]
}
func ExampleQuickSort() {
nums := []int{22, 11, 33, 55, 44, 66}
nums2 := QuickSort(nums)
fmt.Println(nums2)
// Output: [11 22 33 44 55 66]
}
func ExampleInsertionSort() {
nums := []int{22, 11, 33, 55, 44, 66}
fmt.Println(nums)
InsertionSort(nums)
fmt.Println(nums)
// Output: [22 11 33 55 44 66]
// [11 22 33 44 55 66]
}