feat(Go-Tool):新增二分法查找算法及其单测、插入查询及其单测、lomuto划分查询第k小元素及其单测、归并排序及其单测、快速排序及其单测.

This commit is contained in:
huangzj
2020-08-20 09:28:35 +08:00
parent fa58e1a97f
commit c2aca17567
12 changed files with 385 additions and 8 deletions
+42
View File
@@ -0,0 +1,42 @@
/*
* @Author : huangzj
* @Time : 2020/8/19 10:38
* @Description
*/
package search
import (
"fmt"
"testing"
)
func TestInsertionSearch(t *testing.T) {
evenNumList := []int{1, 2, 3, 5, 6, 7, 9, 10, 22, 111, 333, 431}
for _, r := range evenNumList {
position := InsertionSearch(evenNumList, r)
fmt.Println(position)
}
position := InsertionSearch(evenNumList, 999)
fmt.Println(position)
position = InsertionSearch(evenNumList, -10)
fmt.Println(position)
fmt.Println()
oddNumList := []int{1, 2, 3, 5, 6, 7, 9, 10, 22, 111, 333, 431, 3211}
for _, r := range oddNumList {
position := InsertionSearch(oddNumList, r)
fmt.Println(position)
}
position = InsertionSearch(oddNumList, 999)
fmt.Println(position)
position = InsertionSearch(oddNumList, -10)
fmt.Println(position)
}