International Journal of Computer Applications |
Foundation of Computer Science (FCS), NY, USA |
Volume 107 - Number 21 |
Year of Publication: 2014 |
Authors: Nitin Arora, Garima Bhasin, Neha Sharma |
10.5120/19137-9622 |
Nitin Arora, Garima Bhasin, Neha Sharma . Two way Linear Search Algorithm. International Journal of Computer Applications. 107, 21 ( December 2014), 6-8. DOI=10.5120/19137-9622
Linear search is the basic search algorithm used in data structures. If is also called as sequential search. Linear search is used to find a particular element in an array. It is not compulsory to arrange an array in any order (Ascending or Descending) as in the case of binary search. Linear search starts by sequentially scanning the elements in the array and if the element has been found, if will display the particular element and the index value of that element in that array. In this paper we present a novel searching algorithm Two Way Linear Search, which modified version of linear search algorithm and is based on comparing the elements from both ends. We have also compared the Two Way Linear search algorithm with Linear Search Algorithm. We used MATLAB 8. 0 for implementation and Analysis of CPU time taken by both the algorithms. We have checked the algorithms with input sequences of lengths10000, 50000, 100000, and 5000000. Result shows that Two Way Searching Algorithm is working well for all input values and it takes lesser time if the element to be search is after the middle of the array, otherwise it takes same time as in case of linear search.