Various Sorting Algorithm
- Linear search
- Binary search
Linear Search
Array-> 0 1 2 3 4 5 6 7 8 9
data
for i=0 to 9
if data==A[i]
return i;
return-1;
o(n)
Binary Search
1 2 3 4 5 6 7 8 9
40 29 18 90 87 62 53 61 59
sort
29 35 40 53 59 61 62 87 90
m=l+u/2
if(A[m]==data)
return(m);
elseif(data<A[m])
binary_search(A,l,m-1);
else
binary_search(A,m+1,u);