Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with Java homework. Please answer all with correct codes. please (6) (10 points) Binary & Linear Search In this problem, the first line
Need help with Java homework. Please answer all with correct codes. please
(6) (10 points) Binary & Linear Search 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. (c) (2 points) Ensure that your code has good design. (d) (2 points) Ensure that your code has good style. (7) (30 points) In this problem, we will implement a simple dictionary of common words in the English language, represented as an array of words paired with their lengths. You will need to implement each of the below methods in the Dictionary class In this problem, the first line of input represents the method to call. It will be one of the following: MIN, MAX, RANGE, AVERAGE, MODE. The second line will represent an integer n, which denotes the number of words in the list. The following n lines wl each be a word. The words will not necessarily be sorted. Your output should be a single line representing the results of the method. (a) (4 points) Implement the minWordLengthO method, which should (b) (4 points) Implement a method called maxWordLength method, (c) (3 points) Implement a method called wordLengthRangeO, which return the length of the smallest word in the list which should return the length of the largest word in the list should return the range of lengths in the word list (d) (4 points) Implement a method called averageWordLength), which should return the average word length in the word list. The method should return a string representing the average, accurate to exactly two decimal places (i.e. if the average length is 5, return 5.00) (e) (3 points) Implement a method called mostCommonWordLength() which should return the most common length of the words in the list. If there is a tie, you should return -1. You may assume that the length of a word is at most 100 and at least 1 (f) (6 points) Ensure that your code has good design. (g) (6 points) Ensure that your code has good style. (8) (10 points) In this problem, we will implement an nth root finder. Re- call that the nth root of x, written "VT, is the number when raised to the power n gives x. In particular, please fill in the findNthRoot (int number, int n, int precision) method in the class NthRootFinder. The method should return a string representing the nth root of number rounded to the nearest precision decimal places. If your answer is exact you should fill in the answer with decimal places (i.e. with input 41 and precision 5, we should return 41.00000.) You may not use any library functions for this question. In this question, the class NthRootFinder expects 3 lines, where the first line is n (the degree of root to take), the second line is a number, and the third number represents the precision. The output is a single line contain- ing the answer followed by a newline. For example, the following input would generate the output 20.000: 2 400 3 Additionally, the following input would generate the output 6.86: 2 47 2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started