This REPO contains some commonly used array searching techniques
Please ⭐ this repository if you found it helpful so that more people can benifit from this code 😃.
Get current updates on open issues and pull requests
//linear Search
for(int i = 0 ; i < a.length ; i++)
{
if( key == a[i])
{
flag = true;
index = i;
position = i+1;
break;
}
}
while(low <= high)
{
mid = (low + high) / 2;
if( key == a[mid])
{
flag = true;
position = mid+1;
break;
}
else if( key < a[mid] )
{
high = mid -1 ;
}
else if( key > a[mid] )
{
low = mid + 1;
}
}