Question: please use begineer level java language In this problem, we will perform some array swapping. A swap refers to switch positions between two array elements.

please use begineer level java language In this problem, we will performplease use begineer level java language

In this problem, we will perform some array swapping. A swap refers to switch positions between two array elements. For instance, swap the 2nd and 5th elements would mean that the original 2nd element would be put in the 5th position while the original 5th element would be put in the 2nd position. a) Write a function named swap that accepts three argurments, an int array, and two int indices. The function head would appear as public static void swap (int[] inArr, int idx1, int idx2) and use the following array for your test int[] swap Test = {2, 8, 3, 9,5}; A function call to swap such as swap(swap Test, 0, 4) should yield {5, 8, 3, 9, 2}, that is, the first and last elements of the input array are swapped. Implement the demo (or any swap with different indices) in the main method and print the results. b) Write a function named swapMin that accepts an int array, and searches for the minimum element of the input array, then swaps the minimum element with the first element. The function header would appear as public static void swap Min(int [] inArr) and use the following array for your test int[] swap Min Test = {12, 61, 98, 52, 73, 80, -1, 47}; A function call to swap Min such as swap Min(swap Min Test) should yield {-1, 61, 98, 52, 73, 80, 12, 47}. Implement the demo in the main method and print the results. Note: please consider calling the swap function that was implemented in part a) for this function

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!