Add Go codes to docs, including
the chapter of stack and queue, the chapter of tree.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package chapter_searching
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
. "github.com/krahets/hello-algo/pkg"
|
||||
@@ -16,10 +17,10 @@ func TestLinearSearch(t *testing.T) {
|
||||
|
||||
// 在数组中执行线性查找
|
||||
index := linerSearchArray(nums, target)
|
||||
t.Log("目标元素 3 的索引 =", index)
|
||||
fmt.Println("目标元素 3 的索引 =", index)
|
||||
|
||||
// 在链表中执行线性查找
|
||||
head := ArrayToLinkedList(nums)
|
||||
node := linerSearchLinkedList(head, target)
|
||||
t.Log("目标结点值 3 的对应结点对象为", node)
|
||||
fmt.Println("目标结点值 3 的对应结点对象为", node)
|
||||
}
|
||||
|
Reference in New Issue
Block a user