Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science For Dummies

Authors: Lillian Pierson ,Jake Porway

2nd Edition

1119327636, 978-1119327639

More Books

Students also viewed these Databases questions

Question

What are negative messages? (Objective 1)

Answered: 1 week ago