Menu

(Solved) : 40 Points Binary Linear Search Problem Write Binary Linear Search Functions Return Index S Q44088039 . . .

(40 points) Binary & Linear Search In this problem, you will write binary and linear search. For both functions you are to re

(40 points) Binary & Linear Search In this problem, you will write binary and linear search. For both functions you are to return the index of the specified number, or -1 if the number is not in the input list. Also, even if you pass the tests, the TAS will go through the code and ensure you implemented linear search for linear search and binary search for binary search. For example, searching [0, 5, 10] for 10 should return 2. Searching [0,5, 10] for 12 should return -1. (a) In repl.it implement the linearSearch() method. This method should perform linear search on the given input list, and return an index, or -1 if the element doesn’t exist. (b) In repl.it implement the binarySearch() method. This method should perform binary search on the given input list, and return an index, or -1 if the element doesn’t exist. inputArray – a passed in array of integers, not necessarily sorted sortedArray – a sorted array of integers searchTarget – the number you are searching for Helpful hints: You are looking to return the index of the found number. Show transcribed image text (40 points) Binary & Linear Search In this problem, you will write binary and linear search. For both functions you are to return the index of the specified number, or -1 if the number is not in the input list. Also, even if you pass the tests, the TAS will go through the code and ensure you implemented linear search for linear search and binary search for binary search. For example, searching [0, 5, 10] for 10 should return 2. Searching [0,5, 10] for 12 should return -1. (a) In repl.it implement the linearSearch() method. This method should perform linear search on the given input list, and return an index, or -1 if the element doesn’t exist. (b) In repl.it implement the binarySearch() method. This method should perform binary search on the given input list, and return an index, or -1 if the element doesn’t exist. inputArray – a passed in array of integers, not necessarily sorted sortedArray – a sorted array of integers searchTarget – the number you are searching for Helpful hints: You are looking to return the index of the found number.

Expert Answer


Answer to (40 points) Binary & Linear Search In this problem, you will write binary and linear search. For both functions you are …

OR