Say, I am trying to find the largest element in an array, and I write some code as follows.
public class LargestElement
{
public static void main(String[] args)
{
int[] a = {1,2,6,4,5,4,3,1};
int max = a[0];
for(int i = 1;i<a.length;i++)
{
if(a[i] > max)
max = a[i];
}
System.out.println(max);
}
}
Is this called Linear Search?