2016. 12. 8. 11:47

----------------------------------------------------------------------

Hello, i am GameDeveloperPlayground.

I am a Korean student and I post it for English practise.

I would appreciate pointing out grammar or typos.

----------------------------------------------------------------------


In this posting about Linear search.


Linear Search


An alogirthm that searches sequentially from top to bottom.


Time complexity has O(n)


Terminiation condition


If the array find a number in arrays. or if it can not be found until the end, it will be terminiated.



Example Code


1
2
3
4
5
6
7
8
9
10
int Algorithm(int[] arrays, int target)
{
 
    for(int i=0; i<arrays.Length; ++i)
    {
        if(arrays[i] == target)
            return i;
    }
    return -1;
}
cs



It's simple.


Thank you

'Programing > Algorithm' 카테고리의 다른 글

[Algorithm] About Select Sort  (0) 2016.12.08
[Algorithm] About Insertion Sort  (0) 2016.12.08
[Algorithm] About Bubble Sort !!  (0) 2016.12.08
[Algorithm] About Binary Search Algorithm.  (0) 2016.12.08
[Algorithm] About Fibonacci sequence  (0) 2016.12.07
Posted by 시리시안