Java Program for Linear Search.
Linear search is a searching algorithm which sequentially searches element in an array.
In this algorithm, elements of array is scanned one by one and check if it is matching with element to search and if found return true else return false.
In last post, we saw how to do Binary search: Binary Search in Java. In this post, we will focus on linear serach.
Lets understand the problem statement graphically and it will be more clear,
Linear search is a searching algorithm which sequentially searches element in an array.
In this algorithm, elements of array is scanned one by one and check if it is matching with element to search and if found return true else return false.
In last post, we saw how to do Binary search: Binary Search in Java. In this post, we will focus on linear serach.
Lets understand the problem statement graphically and it will be more clear,