Question 1 (30 points) Write a search method search (.....) with four parameters: the search array, the target, the star

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Question 1 (30 points) Write a search method search (.....) with four parameters: the search array, the target, the star

Post by answerhappygod »

Question 1 30 Points Write A Search Method Search With Four Parameters The Search Array The Target The Star 1
Question 1 30 Points Write A Search Method Search With Four Parameters The Search Array The Target The Star 1 (95.54 KiB) Viewed 50 times
Question 1 (30 points) Write a search method search (.....) with four parameters: the search array, the target, the start subscript, and the finish subscript. The last two parameters indicate the part of the array that should be searched. If the target is found, the method returns the index of the first occurrence of the target in the array. If the target is not found, the method returns -1. Your method should catch or throw exceptions where warranted. Question 2 (30 points) Listing 3.1 of your textbook (pages 130-131) shows a JUnit test harness for an array search method (ArraySearch.search) that returns the location of the first occurrence of a target value (the second parameter) in an array (the first parameter) or −1 if the target is not found. Modify the test(s) in the listing to verify a method that finds the last occurrence of a target element in an array.
Question 3 (40 points) Consider the method findLargest () defined as follows: /** * Search an array to find the first occurrence of the * largest element * @param x Array to search * @return The subscript of the first occurrence of the * largest element * @throws NullPointerException if x is null */ public static int findLargest (int[] x) {...} Write the JUnit test harness for the method findLargest().
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply