kelvins / algorithms-and-data-structures

:abacus: Algorithms and Data Structures in several Programming Languages
MIT License
1.04k stars 256 forks source link

added Code of Linear Search in a Recursive way #315

Closed 007AnupamSharma closed 10 months ago

007AnupamSharma commented 10 months ago

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)

007AnupamSharma commented 10 months ago

@kelvins please review the code

007AnupamSharma commented 10 months ago

@kelvins i had made all changes that you want ... would you please review it