Write a java method to search for an element in an array using a linear search. Many list processing tasks, including searching, can be done recursively. The base case typically involves doing...


Write a java method to search for an element in an array using a linear search. Many list processing tasks, including searching, can be done recursively. The base case typically involves doing something with a limited number of elements in the list (say the first element), then the recursive step involves doing the task on the rest of the list.

Think about how linear search can be viewed recursively; if you are looking for an item in a list starting at index i:
o ¬If i exceeds the last index in the list, the item is not found (return -1).
o ¬If the item is at list[i], return i.
o ¬If the is not at list[i], do a linear search starting at index i+1



Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here