Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Were asked to make 3 methods 1. findMax 2. sortSelection 3. swap using Netbeans

ID: 3857982 • Letter: W

Question

Were asked to make 3 methods

1. findMax

2. sortSelection

3. swap

using Netbeans (Java)

Post full answer please

thanks

Recursive Selection Sort private void selectionsort (int arr ti, int last) if (last 0) int maxLoc findMax (arr last) Find largest element. Put in last location swap (arr, last, maxLoc) selection sort (arr, last -1) Move down the array selectionsort 6 8 1 0 10 15 2 32 7 71 After one pass Unsorted Last 6 8 1 0 10 15 2 7 32 71 After two passes Unsorted Last After three 6 8 1 0 10 7 2 15 32 71 passes Unsorted Last 0 1 2 6 7 8 10 15 32 71 After last pass Last

Explanation / Answer

public class Selection { public static void main(String args[]) { int arr[] = {6, 8, 1, 71, 10, 15, 2, 32, 7, 0}; new Selection().selectionSort(arr, arr.length - 1); for (int i = 0; i 0) { int maxLoc = findMax(arr, last); swap(arr, last, maxLoc); selectionSort(arr, last - 1); } } private void swap(int[] arr, int last, int maxLoc) { int temp = arr[last]; arr[last] = arr[maxLoc]; arr[maxLoc] = temp; } private int findMax(int[] arr, int last) { int max = arr[0]; int maxloc = 0; for (int i = 0; i max) { max = arr[i]; maxloc = i; } } return maxloc; } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote