How can i apply the linear search algorithm to this code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i apply the linear search algorithm to this code ?

Using java https://code.sololearn.com/c8mFRTk953H2/?ref=app

28th Sep 2021, 10:15 PM
Sallyariel44
1 Answer
0
Oh yes she is my friend , Can you help us please How can we write it? we need to apply the linear search algorithm to it For example : Given: A list of N elements, and the target 1. index 0 2. Repeat steps 3 to 5 3.Compare target with list[index] 4.if target = list[index] then return index // success else if index >= N - 1 return -1 // failure 5.index index + 1 We take this example in college Martin Taylor
28th Sep 2021, 11:49 PM
Sallyariel44