Question
Write a method whose signature: public void rearrange(int[] a) The method will receive an array a and rearrange its elements so that each element that
Write a method whose signature: public void rearrange(int[] a) The method will receive an array a and rearrange its elements so that each element that is at an odd index in the array will be greater than the element before it and the element after it. It can be assumed that there are no equal elements in the array (each number appears only once). For example, if the method receives this array - {3, 1, 6, 2, 4, 7, 5} A possible rearrangement to the array is: {1, 6, 2, 4, 3, 7, 5} Note that there is more than one possible arrangement. The method should have the best possible runtime efficiency. A method that will have a higher runtime will not receive the full points. B. (5 points) What is the runtime efficiency of the method you wrote? Explain your answer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started