programs based on linear search for class 10 code example
Example: how to do a linear searc in java
public static int linear(int[] arr, int keyValue)
{
int pos = -1;
for (int i = 0; i < arr.length; i++)
{
if (arr[i] == keyValue)
{
pos = i;
break;
}
}
return pos;
}