Question: java programming 1. intlj everyOther(int] a) that creates and returns an array that contains the elements from the even-numbered positions of the array a, that

java programming 1. intlj everyOther(int] a) that creates and returns an arrayjava programming

1. intlj everyOther(int] a) that creates and returns an array that contains the elements from the even-numbered positions of the array a, that is, the elements al0O, a[2], a[4]... Make sure to compute the length of the result array exactly right so that there is no extra element in the end. (You need to consider the possible odd and even lengths of a separately. The integer arithmetic remainder operator % might come handy here.) 2. int countlnversions(intlj a) that counts how many inversions there exist inside the array a. An inversion is a pair of indices (i,j) to the array so that i av]. Use two nested for-loops to loop through all possible pairs of array indices i and j, with the inner loop variablej starting from i + 1 (In the analysis of sorting algorithms, the inversion count is an important measure of how "out of order" the elements of an array are compared to a fully sorted array that has zero inversions. There exists a whole bunch of combinatorics stuff about that.)

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!