Question: Using Java programming language. I need to implement an algorithm that will arrange a given array such that all even numbers are sorted in increasing
Using Java programming language.
I need to implement an algorithm that will arrange a given array such that all even numbers are sorted in increasing order and sorted into even indices. The odd numbers need to be sorted into odd indices but in decreasing order. The finished program should run in big O(n log n).
import java.io.*; import java.util.*; public class SortEvenOdd { /** * Problem 1: Arrange the given array such that all even numbers are in increasing * order at even indices and all odd numbers are in decreasing order at odd indices. */ private static void problem1(int[] arr) { //code here }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
