Linear Search Algorithm : Data Structure

LinearSearch Algorithm:

Linear search is a very simple search algorithm. In this type of search, a sequential search is made over all items one by one. Every item is checked and if a match is found then that particular item is returned, otherwise the search continues till the end of the data collection.

Java Program Example for Linear Search:

public class LinearSearchAlgorithm {

public static void main(String[] args) {
int number, sitem, counter, array[];

Scanner sc = new Scanner(;
System.out.println("Enter the number of elements in array");
number = sc.nextInt();
array = new int[number];

System.out.println("Enter "+ number + " array elements");
System.out.println("length of array is: "+array.length);
System.out.println("Enter element to searched in array");

System.out.println("Search Element "+sitem+" is found in array at location "+(counter+1));

System.out.println("Search Element "+sitem+ "is not in the list");


Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store