Linear searching is a way to find if a certain element (number , string , etc. ) is in a specified array. The array can be in any order, or be completely jumbled and this search will find the element if it is there. If the element is found we can return the index where the element is located in the array. If the element is not found we can return -1. We can assume no array will ever have an negative number as an index. Our approach will be to check every element in the array to see if it is what we are looking for. We will use a loop to cycle through the array. Here goes:
© Nachum Danzig December 2003