public static int countPeaks (int[] data){int numPeaks = 0; for ( missing loop header */ ){if (data[p 1] < data[p] && data[p]> data[p+ 1]){numPeaks++;}}return numPeaks;}Consider the following method, which is intended to return the number of local maximum values in an array. Local maximum values are array elements that are greater than both adjacent array elements. The first and last elements of an array have only a single adjacent element, so neither the first nor the last array element is counted by this method. For example, an array containing the values {3, 9, 7, 4, 10, 12, 3, 8} has two local maximum values: 9 and 12. Which of the following can replace /* missing loop header */ so the method countPeaks works as intended?a. int p = data.length - 1; p > 0; p--b. int p = 0; p < data.length - 1; p++c. int p = 1; p < data.lenght - 1; p++d. int p = 0; p < data.length; p++e. int p = 1; p < data.lenght; p++



Answer :

Other Questions