Answers for "implementation of linear search"

C++
1

what is linear search

A linear search is the simplest method of searching a data set. Starting at the beginning of the data set, each item of data is examined until a match is made. Once the item is found, the search ends.
Posted by: Guest on June-28-2021
0

linear search implementation

def linear_search(lst, target):
    """Returns the index position of the target if found, else returns -1"""

    for i in range(0, len(lst)):
        if lst[i] == target:
            return i
    return -1
Posted by: Guest on December-06-2021

Code answers related to "implementation of linear search"

Browse Popular Code Answers by Language