Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

urgent please type question answer and reason, dont type wrong please! 1 import java.util.Arrays; 3 public class Example1 4 v{ 5V public static void main(String

urgent please type question answer and reason, dont type wrong please! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1 import java.util.Arrays; 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) 7 2) + ain / 2]) 7 2.0; Choose Yes or No for each of the code summaries below if they correctly summarize the above code snippet. foo() finds the median of the array, here it is 5. Yes this os an example of merge sort which follows divide and conquor approach Yes input array is sorted and if the length is not a multiple if two then the value at index n/2 is returned by typecasting it to double Yes No Sort the numbers based on even and odd Yes return the median position number of an array Yes NO size of arrodd getting the middle element arr= even getting the average of 2 middle element Yes No code to find median from the array. So first sort and then find median. Yes No The program takes in array and length of Yes No this code sorts a list of values and finds the median value Yes No The code initialises an array and calls the foo function sending the array and its length. The foo function sorts the array and checks the length. If the length of the array is an odd number it return the element at the length/2 index of the sorted array Yes No As we can see the total numbers are 9 and the program focuses on array sorting. Yes No 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 A method is called that returns the median of a given array Yes No w ey software X + ..ca1.qualtrics.com/jfe/form/SV_OrHwu5cnFg|P8dD This code finds the median term of an input array. Yes No it is used to find the median in an array Yes No It sortsan array of integers and, if there are an odd number of elements, returns the middle element It sorts an array of integers and, if there are an odd number of elements, returns the middle element. Otherwise, it returns the sum of the middle two elements. 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 sorting the array and returning the element array[4] Yes No The code computes median in an array. Yes No dite lonth to a function. In this programme, we took an array, pass the array and its length to a function. Perform few operations and return the double value. And finally print the value Yes No the function returns a[4.5), hence the element 5 then it returns (a[5.5]), hence element 6 Yes No To get the middle number in the array. Yes No To judge if length of array is a odd number. If it is, print float middle number. 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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions