Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package practicePackage._06_sorting.attempts; public class Stage3 { /** * * @param data * @return the array after it has been sorted so that all the odd

package practicePackage._06_sorting.attempts;

public class Stage3 {

/**

*

* @param data

* @return the array after it has been sorted so that all the odd numbers are

* sorted after the even numbers. The two groups should be sorted in

* ascending order.

*/

public static int[] sortOddEven(int[] data) {

return null; //to be completed

}

package practicePackage._06_sorting.testAttempts;

import static org.junit.jupiter.api.Assertions.*;

import java.util.Arrays;

import org.junit.jupiter.api.Test;

import practicePackage._06_sorting.attempts.*;

public class TestStage3 {

@Test

public void testSortOddEven() {

assertNull(Stage3.sortOddEven(null));

assertEquals("[10, 20, 70]", Arrays.toString(Stage3.sortOddEven(new int[] { 20, 70, 10 })));

assertEquals("[-75, 15, 25]", Arrays.toString(Stage3.sortOddEven(new int[] { 25, -75, 15 })));

assertEquals("[4, 10, 20, 70, 5, 11]", Arrays.toString(Stage3.sortOddEven(new int[] { 11, 20, 5, 70, 10, 4 })));

assertEquals("[-4, 10, 20, 70, -11, -5]",

Arrays.toString(Stage3.sortOddEven(new int[] { -4, 20, 70, -5, 10, -11 })));

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

What is an influential observation? Give a few examples.

Answered: 1 week ago