Linear Search Applications

We use linear search in following things:

• For search item in the smaller array.
• For fast searching 
The time complexity of the above algorithm is O(n).

Please refer complete article on Linear Search for more details!



Java Program for Linear Search

Given an array arr[] of n elements, write a function to search a given element x in arr[]. 

ALGORITHM for Linear Search

Step 1: Start 
Step 2: Declare an array and search element as key.
Step 3: Traverse the array until the number is found.
Step 4: If the key element is found, return the index position of the array element
Step 5: If the key element is not found, return -1
Step 6: Stop.

Pseudocode for Linear Search

PROCEDURE LINEAR_SEARCH (LIST, VALUE)
  FOR EACH ITEM IN THE LIST
     IF SAME ITEM == VALUE
          RETURN THE ITEM’S LOCATION
     END IF
  END FOR
END PROCEDURE

Similar Reads

Linear Search in Java

Below is the implementation of Linear Search in Java:...

Linear Search Applications

...

Contact Us