0
/ 40
Complete the following linear search method. Find the number search
in the array numbers
. If the number is found, return the index for...
Complete the following linear search method. Find the number search
in the array numbers
. If the number is found, return the index for the position. If the number is not found, return the index of the last position checked. The array is sorted in increasing value (lower values appear first), thus your routine must stop once the code has deterrmined the value is not there.
Examples:
linearSearch({2,4,9},7) -> 2
linearSearch({2,4,9},3) -> 1
linearSearch({2,4,9},1) -> 0
linearSearch({2,4,9},50) -> -1
Your feedback will appear here when you check your answer.