Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

def LinearSearch(array, n, k):

def LinearSearch(array, n, k):

    for j in range(0, n):

        if (array[j] == k):

            return j

    return -1

 
array = [1, 3, 5, 7, 9]

k = 7
n = len(array)

result = LinearSearch(array, n, k)

if(result == -1):

    print("Element not found")

else:

    print("Element found at index: ", result)
Comment

def LinearSearch(array, n, k):

def LinearSearch(array, n, k):

    for j in range(0, n):

        if (array[j] == k):

            return j

    return -1

 
array = [1, 3, 5, 7, 9]

k = 7
n = len(array)

result = LinearSearch(array, n, k)

if(result == -1):

    print("Element not found")

else:

    print("Element found at index: ", result)
Comment

PREVIOUS NEXT
Code Example
Python :: image processing for GC 
Python :: table is not creating in django 
Python :: django annotate datetime field to char 
Python :: Filter by len() 
Python :: <function chr(i, /)> error in python 
Python :: python record screen and audio 
Python :: Method to get column average 
Python :: python geopandas read layer from gdb 
Python :: which company has the largest servers 
Python :: flask get summernote text 
Python :: onlinecourses.osppro.com 
Python :: add a third dimension matrix dataset python 
Python :: create empty polygon python 
Python :: ler arquivo xls no pandas 
Python :: code runner runs python 2 
Python :: fix certain parameters during curve fit python lambda 
Python :: how to write string in python 
Python :: discord.py assign role 
Python :: add many instances to related field manytoamny django] 
Python :: fibonacci sequence script python 
Python :: execute command from url.script 
Python :: matplotlib FiveThirtyEight creating a signature 
Python :: how to add another timestamp column plus two hours 
Python :: django force download file 
Python :: mechanize python #9 
Python :: how to visualize pytorch model filters 
Python :: chain lists 
Python :: Pandas column of lists, create a row for each list element 
Python :: # difference between list 1 and list 2 
Python :: R[~i] in python 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =