linear search==>checking each element one by one in an array until we finding the target value
arr[]={1,2,3,…….100};
target value=3
class Linear
{
public static void main(String args[])
{
int arr[]={1,2,3,4,5,6,7,8,9,10};
int key=11;
boolean yes=false;
for(int i=0;i<=10;i++)
{
if(arr[i]==key)
{
System.out.println(“element found at=”+(i+1));
yes=true;
break;
}
}
if(!true)
System.out.println(“element not found”);
}}