Files
hello-algo/ja/codes/go/chapter_searching/linear_search_test.go
Yudong Jin d7b2277d2b Re-translate the Japanese version (#1871)
* Retranslate Japanese docs with GPT-5.4

* Retranslate Japanese code with GPT-5.4
2026-03-30 07:30:15 +08:00

27 lines
645 B
Go

// File: linear_search_test.go
// Created Time: 2022-11-25
// Author: Reanon (793584285@qq.com)
package chapter_searching
import (
"fmt"
"testing"
. "github.com/krahets/hello-algo/pkg"
)
func TestLinearSearch(t *testing.T) {
target := 3
nums := []int{1, 5, 3, 2, 4, 7, 5, 9, 10, 8}
// 配列で線形探索を行う
index := linearSearchArray(nums, target)
fmt.Println("対象要素 3 のインデックス =", index)
// 連結リストで線形探索を行う
head := ArrayToLinkedList(nums)
node := linearSearchLinkedList(head, target)
fmt.Println("対象ノード値 3 に対応するノードオブジェクト =", node)
}