YouTip LogoYouTip

Python Linear Search

# Python3.x Python Linear Search [![Image 4: Document Object Reference](#) Python3 Examples](#) Linear search involves checking each element in an array in sequence until the desired specific value is found. !(#) ## Example def search(arr, n, x): for i in range(0, n): if(arr == x): return i return -1# Search for character D in array arr arr = ['A', 'B', 'C', 'D', 'E']x = 'D'n = len(arr)result = search(arr, n, x)if(result == -1): print("Element is not in array")else: print("Element is at index", result) Executing the above code outputs: Element is at index 3 [![Image 6: Document Object Reference](#) Python3 Examples](#)
← Python QuicksortPython Merging Two Dictionarie β†’