Question: I need the answer for E and please with explanation. The code public class ArraySortByFirst { /** * Sorts an array of integers by the

 I need the answer for E and please with explanation. TheI need the answer for E and please with explanation.

The code

public class ArraySortByFirst

{

/**

* Sorts an array of integers by the first value of each row. After

* sorting, the first column of the array is in ascending order.

*/

public static void sortByFirst(int data[][])

{

}

/**

* Finds the index of the smallest value in a portion of an array.

*/

private static int getIndexOfSmallest(int[][] a, int first, int last)

{

}

/**

* Swaps the rows a[i] and a[j].

*/

private static void swap(int[][] a, int i, int j)

{

}

/**

* Displays the two-dimensional array.

*/

public static void display(int data[][])

{

}

/**

* Tester

* You do not need to change any code in the main method

*

*/

public static void main(String args[])

{

int array[][] = {{1, 2, 3, 4, 5},

{3, 4, 5, 1, 2},

{5, 2, 3, 4, 1},

{2, 3, 1, 4, 5},

{4, 2, 3, 1, 5}};

System.out.println("The array is initially " );

display(array);

System.out.println();

sortByFirst(array);

System.out.println("The array after sorting is " );

display(array);

System.out.println();

}

}

: run The array is initially D. -- 2 points -- Suppose you want to find the largest entry in an unsorted array of n entries. Algorithm A searches the entire array sequentially and records the largest entry seen so far. Algorithm B sorts the array into descending order and then reports the first entry as the largest. Compare the time efficiency of the two approaches. 1 23 4 5 345 12 23 2 3 1 45 E. -- 10 points -- Consider an n by n array of integer values. Write an algorithm to sort the rows of the array by their first value. 4 2 3 1 5 Implement your algorithm. The array after sorting is 1 2 3 4 5 2 31 45 The code for this problem is provided in the Assignment-03-Code.zip archive. Your output must be identical to the output to the right 345 12 23 23 41

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!