Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Data File StructureRSS Feeds

Defines and differentiates sequential search and binary search

Posted By: Viveka Fischer     Category: C++ Programming     Views: 5456

This article defines and also differentiates about sequential search and binary search.

Sequential Search

The simplest technique for searching an unordered table for a particular record is to scan each entry in the table in a sequential manner until the desired record is found.

Binary Search

The entries in table are stored in alphabetically or numerically increasing order.  The approximate middle entry of the table is located, and its key value is examined.  If its value is too high, then the key value of middle entry of first half of table is examined and procedure is repeated on first half until the required item is found.  If value is too low, then key of middle entry of second half of the table is tried and procedure is repeated on second half.


Difference of sequential search and binary search

  Sequential Search

 Binary Search

 It is easy.

It is complicated.

 It needs not to be sorted.

It needs to be sorted.

 To search the last element we have to scan all the elements.

To search the last element we don't have to search all elements.

 If the element is first, then it’s best  case bcoz the element is found at first position.

If the element is first, then also we have to check for some of  the elements (average case).


  
Share: 



Viveka Fischer
Viveka Fischer author of Defines and differentiates sequential search and binary search is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!