java速度帮我看下怎么写

For this problem, you have to write methods in Java to sort an integer array in non-decreasing order using the selection sort algorithm. This algorithm sorts an array by repeatedly finding the smallest element of the unsorted tail region and moving it to the front. You have to write code just for the methods indexOfMinElement and swap using the skeletons given below.

nt []score ; // Assume that integer array score is appropriately // initialized and available to all methods below public void sort() // code for this method is specified below { for (int i = 0; i < score.length – 1; i++) { int minIdx = indexOfMinElement (i); swap (minIdx, i); } }// end sortpublic int indexOfMinElement(int startIdx){ // Returns the index of the smallest array element from startIdx to end// of the array // Write code for this method below }// end indexOfMinElementpublic void swap(int i, int j){ // Swaps the array elements score[i] and score[j] // Write code for this method below }// end swap

 

 The Java class ArrayList is a useful data structure to handle arrays when the size of an array is not known a priori. An ArrayList named balance of type integer is created as follows:ArrayList<Integer> balance = new ArrayList<Integer>();To add an element to an ArrayList, use the method add. For example,balance.add(42) adds the value 42 to the end of the ArrayList balance.To retrieve the value of an element, use the method get. For example,balance.get(i) returns the value of the element with index position i in the ArrayList balance(recall that an ArrayList uses a zero-based index).To determine the size of an ArrayList, use the method size. For example,balance.size() returns the number of elements in the ArrayList balance.Write code below for a method reversethat takes in an integer ArrayList named data as a parameter and returns an ArrayList whose elements are in reverse order of the input ArrayList. The elements of the input ArrayList should not be modified by your method.public static ArrayList<Integer> reverse(ArrayList<Integer> data){// If the input ArrayList is [4, 3, -2, 9] the returned ArrayList should be //[9, -2, 3, 4] // Your code should appear below} // end reverse

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^