이 기사에서는 선형 검색과 Python 3.x에서의 구현에 대해 배웁니다. 또는 그 이전.
알고리즘
Start from the leftmost element of given arr[] and one by one compare element x with each element of arr[] If x matches with any of the element, return the index value. If x doesn’t match with any of elements in arr[] , return -1 or element not found.
이제 주어진 접근 방식의 시각적 표현을 봅시다 -

예
def linearsearch(arr, x):
for i in range(len(arr)):
if arr[i] == x:
return i
return -1
arr = ['t','u','t','o','r','i','a','l']
x = 'a'
print("element found at index "+str(linearsearch(arr,x))) 출력
element found at index 6
변수의 범위는 그림에 나와 있습니다 -

결론
이 기사에서 우리는 Python3.x의 선형 검색 메커니즘에 대해 배웠습니다. 또는 그 이전.