Linier Search


This method of searching is also known as sequential search.
Linier search work on both sorted as well as unsorted list.
This method of searching works as follows:
Suppose we want to search an element X from the list of N elements. First the element X is compared with the 1st element in the List. If the element is matched then search is successful.
If the element is not matched then the element X is compared with next element and this process is repeated until match is found or all the elements in the list are compared.
Consider the following example:
The list consist of 5 elements as shown below:

Index
Element
A[0]
11
A[1]
33
A[2]
55
A[3]
22
A[4]
44
     

Suppose we want to find 55 in the list. So 55 is compared with the first element in the list which is 11.

Index
Element
   
A[0]
11
Match Not Found
A[1]
33
   
A[2]
55
   
A[3]
22
   
A[4]
44
   

Since match is not found 55 is compared with next element in the list and this process is repeated until match found or all elements in the list is compared as shown below.

Index
Element
   
A[0]
11
   
A[1]
33
Match Not Found
A[2]
55
   
A[3]
22
   
A[4]
44
   

 

Index
Element
   
A[0]
11
   
A[1]
33
   
A[2]
55
Match Found
A[3]
22
   
A[4]
44
   

Download Projects


Download Programs