Data Structures and Algorithms - Linear Search

Hello Guyz,
Today I'm going to show you linear search algorithm with coding examples.In computer science, linear search or sequential search is a method for finding a particular value in a list that checks each element in sequence until the desired element is found or the list is exhausted. The list need not be ordered.



Linear search is the simplest search algorithm; it is a special case of brute-force search. Its worst case cost is proportional to the number of elements in the list. Its expected cost is also proportional to the number of elements if all elements are searched equally. If the list has more than a few elements and is searched often, then more complicated search methods such as binary search or hashing may be appropriate. Those methods have faster search times but require additional resources to attain that speed.

Time Complexity of Linear Search is : O(N)

  


-Vishva Rodrigo-

No comments:

Post a Comment