Last active
May 28, 2018 10:05
-
-
Save clara-shin/43a4b210a67699c760f4ac01ae2e2664 to your computer and use it in GitHub Desktop.
순차탐색 알고리즘
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sequentialSearch(arr,n,x){ | |
for(let i=0; i < n; i++){ | |
if(x === arr[i]) return i; | |
} | |
return -1; //탐색실패 시 리턴 -1 | |
} | |
/* | |
arr=[0,1, ...n-1];에서 x를 찾는 알고리즘 | |
배열 arr, n 은 data 개수, x 는 찾고자 하는 data | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment