Question: Searcher.java import java.lang.UnsupportedOperationException; import java.util.Scanner; public class Searcher { public static final int LINEAR_SEARCH_OPTION = 0; public static final int BINARY_SEARCH_OPTION = 1; public static

Searcher.java
import java.lang.UnsupportedOperationException; import java.util.Scanner;
public class Searcher { public static final int LINEAR_SEARCH_OPTION = 0; public static final int BINARY_SEARCH_OPTION = 1; public static void main(String[] args) { Scanner sc = new Scanner(System.in); // parse the search method int searchMethod = Integer.parseInt(sc.nextLine()); // parse the number to find int n = Integer.parseInt(sc.nextLine()); // parse the list of numbers to search in String[] numberStrings = sc.nextLine().split(" "); int[] numbers = new int[numberStrings.length]; for (int i = 0; i
Fill in the starter code, and include comments(beginner here)
Code using java
In this problem, the first line of input represents the type of search used where 0 will indicate linear search and 1 will indicate binary search. The second line will represent an integer to find in a list. The third line will represent a space-separated list of numbers to search through. The output is a single line stating true if the integer is contained in the given list of numbers or false if it is not. For example, the following input should produce an output of true: 4 0 1 3 7 8 1000000 4 5 (a) (3 points) In the file Searcher.java, implement the linearSearch() method. This method should perform linear search on the given input list, and return true iff (if and only if) the desired integer is in the list (b) (3 points) In the file Searcher.java, implement the binarySearch() method. This method should perform binary search on the given input list, and return true iff (if and only if) the desired integer is in the list. You may assume the list is sorted
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
