Linear search algorithm is most basic search that we do in our regular life. For example while searching one of the cloth from heap of cloths, or finding key from bunch of keys. When you have random list of thing where you don’t know order of things in the collection or array then its better if you do the linear search than anything else.
e.g. you have various number plats in box from 0-9. You have to find number plate with number 7 and you can only check one plate at a time. Then its good if you start puling one and checking if it is number 7 else throw it away.
Hence by this algorithm you can solve a problem of n size in worst case scenario in O(n) time (in big O notation). As size grows the time grows by the size of problem. Many of the common programming things use this e.g LINQ, JQuery to find particular item.
Code example of linear search algorithm:
for( int i =0; i < values.Length;i++)
if(values[i] == numberToFind)
This function returns index of number found else -1 to suggest that number is not in collection.