it is defined as a sequential search algorithm that starts at one end and goes through each element of a list until the desired element is found, otherwise the search continues till the end of the data set.
Linear search works by comparing each element of the data structure with the key to be found.
LinearSearch (array, index, key):
if index < 0:
return -1;
if item = key:
return index
return LinearSearch (array, index-1, key)
Description
it is defined as a sequential search algorithm that starts at one end and goes through each element of a list until the desired element is found, otherwise the search continues till the end of the data set.
Linear search works by comparing each element of the data structure with the key to be found.
LinearSearch (array, index, key): if index < 0: return -1; if item = key: return index return LinearSearch (array, index-1, key)