Thursday, March 28, 2019

LINEAR (OR) SEQUENTIAL SEARCH


  • This is the simplest known techniques for searching an array for a particular record or data element.
  • In  LINEAR  search we start with the first available element,that is the element that comes  first.
  • If this is the required element then our search is over,else we take up the second element and see if this is the element that we need.
  • If this too is not the require element then we pick up third element.
  • This process of considering the next record will go on till we find required element or all the elements in the table are empty.

EXAMPLE

        

To find the 61 from the given list.
        
61!=4,so we move the pointer to the next position,
           
          
61!=21,so we move the pointer to the next position,
        
            
61!=36,so we move the pointer to the next position,

             
61!=15,so we move the pointer to the next position. 

                 
  •  Element 61 is in the position 4.

Efficiency:

  • The efficiency of linear (or) sequential search is O(n).  

Advantages:    

  • It is a simple searching technique that is easy to implement.
  • It does not require the list to be sorted in a particular order.
Disadvantages:

  • It is quite inefficient for large sized lists.
  • It does not leverage the presence of any pre_existing  sort order in a list.
                               *****    








         

No comments:

Post a Comment