Question: An alternating sorted array is an array in which all the numbers in the even indexes are sorted in ascending order, and all the numbers
An alternating sorted array is an array in which all the numbers in the even indexes are sorted in ascending order, and all the numbers in the odd indexes are sorted in descending order. For example, the following array is sorted alternately: 3 40 9 17 11 5 14 3 15 1 9 8 7 6 5 4 3 2 1 0 Write a method whose signature - public static int find(int[] a, int x) The method will receive as parameters an alternately sorted array as described, and a number x. The method will return the index where x appears in the array (if it does) or -1 if it doesn't. For example, for the array above and the number 11, the method will return 5 (11 is at index 5). And for the number 29 the method will return -1. Note - the method should have the best possible runtime efficiency. A method that is not maximally efficient will not receive full points. B. (5%) What is the runtime efficiency of the method you wrote? Explain your answer.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
