Question: please post clear answers! and type question with answer posted before got incorrect ones! por Jdvd.util.Arrays; WN 3 public class Example1 4 v{ 5v public

please post clear answers! and type question with answer posted before got incorrect ones!  please post clear answers! and type question with answer posted before
got incorrect ones! por Jdvd.util.Arrays; WN 3 public class Example1 4 v{
5v public static void main(String args[]) { int arr[] = { 1,
3, 4, 2, 7, 5, 8, 6, 10 }; int var =
arr.length; System.out.println(foo(arr, var)); public static double foo(int al], int n) { Arrays.sort(a);

por Jdvd.util.Arrays; WN 3 public class Example1 4 v{ 5v public static void main(String args[]) { int arr[] = { 1, 3, 4, 2, 7, 5, 8, 6, 10 }; int var = arr.length; System.out.println(foo(arr, var)); public static double foo(int al], int n) { Arrays.sort(a); if (n % 2 != 0) { return (double)a[n/ 2]; return (double)(al(n - 1) / 2] + a[n / 2]) / 2.0; starts with an array with 9 elements, then sorts the array. Then checks if n (length of array) is even or odd. if odd, it will return the element in the middle left. else, it will return, the element in the middle, just using a different formula since an array with even number does not have a true middle. Yes No The code computes median in an array. Yes No To get the middle number in the array. Yes size of arr = odd getting the middle element arr- even getting the average of 2 middle element Yes No This code finds the median term of an input array Yes No To judge if length of array is a odd number. If it is, print float middle number. Yes No ife/form/SV_OrHwu5cnFgIP8dD It sorts an array of integers and, if there are an odd number of elements, returns the middle element. Otherwise, it retums the sum of the middle two elements. Yes No As we can see the total numbers are 9 and the program focuses on array sorting. Yes No The functions foo sorts the array to 1,2,3,4,5,6,7,8,10 and then returns 7 The main function prints 1,2,3,4,5,6,7,8,10,7 Yes No the function retums a[4.5] , hence the element 5 then it returns (a[5.5]), hence element 6 Yes No A method is called that returns the median of a given array. Yes No The program takes in array and length of Yes No

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!