-
[알고리즘] 순차 탐색 (Sequential Search)Algorithms & Data Structure 2021. 8. 18. 19:48
순차 탐색 (Sequential Search)
- 리스트를 앞에서부터 순서대로 비교하는 탐색 방법.
순차 탐색 구현 방법
from random import * rand_data_list = list() for num in range(10): rand_data_list.append(randint(1, 100))
rand_data_list
Out[2]:
[65, 21, 75, 43, 86, 98, 32, 51, 58, 13]
def sequential(data_list, search_data): for index in range(len(data_list)): if data_list[index] == search_data: return index return False
sequential(rand_data_list, 4)
Out[6]:
False
GitHub - DAWUNHAN/Algorithms-and-DataStructure: Algorithms and DataStructure with Python
Algorithms and DataStructure with Python. Contribute to DAWUNHAN/Algorithms-and-DataStructure development by creating an account on GitHub.
github.com
'Algorithms & Data Structure' 카테고리의 다른 글
깊이 우선 탐색 (Depth-First Search) (0) 2021.08.20 [알고리즘] 너비 우선 탐색 (BFS) (0) 2021.08.20 [알고리즘] 이진 탐색(Binary Search) (0) 2021.08.18 [알고리즘] 병합 정렬 Merge Sort (0) 2021.08.18 [알고리즘] 퀵 정렬 Quick Sort (0) 2021.08.18