Please formulate the sum equation for this proof. I'm confused on how to do it.

icon
Related questions
Question

Please formulate the sum equation for this proof. I'm confused on how to do it.

package task1;
import java.util.*;
public class Main {
}
public static void main(String[] args) {
int[] arr = {16, 17, 4, 3, 5, 2};
List<Integer> dominantElements = findDominantElements (arr);
System.out.println("Dominant elements in the array: + dominantElements);
11
}
1 usage
public static List<Integer> find DominantElements (int[] arr) {
List<Integer> result = new ArrayList<>();
int maxSoFar = arr[arr.length - 1];
}
result.add(maxSoFar);
for (int i = arr.length 2; i >= 0; i--) {
if (arr[i] > maxSoFar) {
maxSoFar = arr[i];
result.add(maxSoFar);
}
}
Collections.reverse(result);
return result;
Transcribed Image Text:package task1; import java.util.*; public class Main { } public static void main(String[] args) { int[] arr = {16, 17, 4, 3, 5, 2}; List<Integer> dominantElements = findDominantElements (arr); System.out.println("Dominant elements in the array: + dominantElements); 11 } 1 usage public static List<Integer> find DominantElements (int[] arr) { List<Integer> result = new ArrayList<>(); int maxSoFar = arr[arr.length - 1]; } result.add(maxSoFar); for (int i = arr.length 2; i >= 0; i--) { if (arr[i] > maxSoFar) { maxSoFar = arr[i]; result.add(maxSoFar); } } Collections.reverse(result); return result;
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer