Answers for "Suppose you have implemented the SelectionSortArray class. Add a method called median() to the SelectionSortArray class in the SelectionSortArray.java program. This method should return the median value in the array"

5

selection sort in java

public static void SelectionSort(int[] arr)
{
  int small;
  for (int i = 0; i <arr.length - 1; i++)
  {
    small = i;
    for (int j = i + 1; j < arr.length; j++)
    {
      //if current position is less than previous smallest
      if (arr[j] < arr[small])
      {
        small = j;
        
        //swap values
        int temp = arr[i];
        arr[i] = arr[small];
        arr[small] = temp; 
      }
  	}
  }
}
Posted by: Guest on May-06-2020

Code answers related to "Suppose you have implemented the SelectionSortArray class. Add a method called median() to the SelectionSortArray class in the SelectionSortArray.java program. This method should return the median value in the array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language