Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write up a Java method using recursion that reorders an integer array in such a way that all the even values comes before the odd
Write up a Java method using recursion that reorders an integer array in such a way that all the even values comes before the odd values. output should be 8 6 2 4 4 4 4 3 5 5 3 7 1 9
Here is the code to start, fill in the missing part
public class MyClass { static void organize(int[] data, int low, int high) { //code here // Hint: one way is to code similar to binary search and use the // low and high //code here } static void organize(int[] data) {//helper function organize(data, 0, data.length - 1); } public static void main(String args[]) { int[] data = {1,2,3,3,4,4,4,4,5,5,6,7,8,9}; organize(data); for (int i : data) { // accessing each element of array System.out.print(i + " "); } } }
2.
3. Given the following code
Given the tree bellow 3 5 9 20) 20 8 (12) (30) 146 10 what is the preorder? (11) (21)(31)
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