Computer Science, asked by nishuanil112005, 5 months ago

Write a program to accept 10 different numbers in a single dimensional array . Search for a given number using linear search technique​

Answers

Answered by jai696
4

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

def linear_search(arr, n):

for idx, item in enumerate(arr):

if n == item:

return idx

return -1

nums = [int(n) for n in input("enter 10 nums: ").split()]

n = int(input("enter num to search: "))

idx = linear_search(nums, n)

if idx > -1:

print(f"item found at idx: {idx}")

else:

print("item not found")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions