Answers for "char sort using lenear search"

2

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;
}
Posted by: Guest on April-15-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language