Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with 5.5. this is the code I attempted but it does not return the co

ID: 3576570 • Letter: I

Question

I need help with 5.5. this is the code I attempted but it does not return the correct values.

ArrayUtils. without (input, ArrayUtils. without (input ArrayUtils without (input, 3 5.5 into interleave(intO a, int0 b) Given two arrays, a and b, of the same length, return a new array where the first element is a's first element, the second element is b's first element, the third is a's second element, the fourth is b's second element, and so on. If a and b are not the same length, return null int new int int new int 12, 2, 2 Array Util Array Util Array Util 5.6 into splice(int[l a, int offset, intOb) Given an integer array a, and an offset index within a, return a new array with b's elements'spliced" into array a starting at the given offset. Array Utils. splice (a ArrayUtils. splice (a 1, b) ArrayUtils. splice (b 19 3, 9 ArrayUtils-splice (b, 2, a 19, 9, 1 2, 3 H Package Explorer 3 5 Array Utils.java X DJ TestRunnerjava 241 242 return lala 6F-PS00-GottaCatchEmAll [1 243 6F-PS02-BumperGames [16l 16F-PS03-Paternity Test [16F. 245 public static intCJ interleave CintCJ a, intCJ b) 6F-PS04-ReviewBot 6F-PS 246 int i 6F-PS05-Compstag [16F 247 int j 248 int k 6F-PST 6F-PS1-Em 249 intO c new intla length b length] 16F-WS00-TriviaBox [16F-WS 250 16F-ws01-Hotlineeling [16F- if a length b length) 251 6F-WS01-HotlineBling2 [16F. 252 return null; 16F-WS02-Array Utils [16F-WS 253 254 while Ci c length) 255 if (i 2 0) comp110 256 CCij ArrayUtils,java 257 estRunner java 258 k++ E JRE System Library Java S 259 6F-WS03-Midterm Retry 260 v6 Lecture Lecture master) else 261 262 CCij Src al J. comp110.lecture0 263 J++ 264 comp110.lecture02 265 comp110.lecture03 266 comp110.lecture04 267 Calc ulatorjava 268 return CalculatorRunnerjav 269 eRunnerjava. 270 dH> p110.lecture05 Console X Problems Declaration H> comp110.lecture06 comp110.lecture07 comp110.lecture08 xterminated TestRunner Dava Application] avavirt 101.jdk ContentsHome/bin ualMac comp110.lecture09 7852e922 comp110.lectureel aud CIe4e25154f comp110. lecture sha comp110.lecture12 H comp110.lecture13

Explanation / Answer

HI, Please find my implementation.

Please let me know in case of any issue.

public class Interleave {

  

   public static int[] interleave(int[] a, int[] b){

      

       if(a.length != b.length)

           return null;

      

       // creating new array of double length as a or b

       int[] c = new int[a.length*2];

       int i = 0; // index of a

       int j= 0; // index of b

       int k = 0; // index of c

      

       while(k < c.length){

           c[k++] = a[i++];

           c[k++] = b[j++];

          

       }

      

       return c;

   }

  

   public static void main(String[] args) {

  

       int[] a = new int[]{1,1,1};

       int[] b = new int[]{2,2,2};

      

       int[] c = interleave(a, b);

      

       for(int i=0; i<c.length; i++){

           System.out.print(c[i]+" ");

       }

       System.out.println();

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote