Question: I need help on private static int getIndexOfSmallest and the rest to check Code: public class ArraySortByFirst { /** * Sorts an array of integers

I need help on private static int getIndexOfSmallest and the rest to check
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();
}
}
The array is initially 1 2 3 45 3 4 5 1 2 5 2 3 4 1 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 3 1 45 Your output must be identical to the output to the right. 4 2 3 1 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
