Question: (a) Design the recursive linear Search method that, when given a String [] S and a String to search for k, returns the index
![(a) Design the recursive linear Search method that, when given a String [] S and a String to search for k,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/answers/2023/10/651d9f7705fea_183651d9f77000b7.jpg)

(a) Design the recursive linear Search method that, when given a String [] S and a String to search for k, returns the index of k in S, and -1 if k is not in the array. Since this method is definitionally tail recursive, you should write a private helper method that actually performs the recursion. (b) Design the linear SearchLoop method that solves the problem using a loop. If you write tests for one of these methods, you should be able to propagate it to the other, so write plenty! For this problem you are not allowed to use an ArrayList or any helper methods, e.g., .contains, or methods from the Arrays class. You may (and should!) use a HashSet to keep track of previously-seen peaks. (a) Joe the mountain climber has come across a large mountain range. He wants to climb only the tallest mountains in the range. Design the peakFinder method that returns an array H' of all the peaks in an int [] of mountain heights H. A peak p is defined as an element of h at index i such that p[i 1] < p[i] and p[i] > p[i+1]. If i = 0 or i = |H|-1, Joe will not climb p[i]. Joe doesn't want to climb a mountain of the same height more than once, so you should not add any peaks that have already been added to H'. We present some test cases below. Hint: reuse the linear search algorithm from problem 1, except switch the String parameter for integers. peakFinder ({9, 13, 7, 2, 8}) -> {13} peakFinder ({8, 7, 8, 7, 8, 7, 8, 7}) -> {8} peakFinder({111, 27, 84, 31, 5, 9, 4, 3, 2, 1, 64}) -> {84, 9} peakFinder ({}) -> {} peakFinder({1}) -> {} peakFinder ({1, 2}) peakFinder({1, 2, 1}) peakFinder({1, 2, 3, 2, 1}) -> {} -> {2} -> {3} (a) A professor gives their students extra credit on an exam if they can guess the average within five percent of the actual average. Design the isGivenExtraCredit method that, when given an ArrayList D and a guess g, returns whether a student is given extra credit. (b) A village has members where each has a partner. These members are grouped in pairs inside an ArrayList where each pair of indices represents a relationship of the village. I.e., A.get (21) and A.get (2i+1) are in a relationship. A couple is considered the wisest if they have the highest combined age. Write the wisest method that, when given an ArrayList A, return a new ArrayList containing the ages of the wisest pair. If there is a tie, return the pair that has the highest age overall. The order is not significant. We present a few test cases below. You can assume that there will always be an even number of village members. wisest ((31, 42, 43, 35, 21, 27, 24, 44} -> (43, 35) or {35, 43) wisest ({47, 51, 52, 48, 33, 67, 45, 35)-> (33, 67) or (67, 33} (c) Design the tokenize method that, when given a Strings and a char delimiter d, returns an ArrayList of tokens split at the delimiter. You must do this by hand; you cannot call any String methods (except .length and .charAt).
Step by Step Solution
3.44 Rating (157 Votes )
There are 3 Steps involved in it
The image you have shared contains three separate programming problems each asking for a different algorithm to be designed or implemented I will addr... View full answer
Get step-by-step solutions from verified subject matter experts
