Question: please help ASAP don't use Any Java library class (e.g., ArrayList, Arrays) /* * Input Parameters: * - `seq`: a non-empty array of integers *

please help ASAP

don't use Any Java library class (e.g., ArrayList, Arrays)

/* * Input Parameters: * - `seq`: a non-empty array of integers * - `n`: a non-negative integer * * Assumptions: * - Input array `seq` is not empty. * - Input integer `n` is non-negative (>= 0). * * What to return? * - Given an array `seq` of integers and an integer `n`, * return a new array whose elements correspond to those of `seq` by * shifting every element in `seq` to the right by `n` positions. * - The shifts are ***circular***: * any elements that would "go off the boundary" are * wrapped around back from the beginning of the array. * * See the JUnit tests related to this method. */ public static int[] task2(int[] seq, int n) { int[] result = null; /* Your task is to implement this method, * so that running TestUtilities.java will pass all JUnit tests. * * Recall from Week 1's tutorial videos: * 1. No System.out.println statements should appear here. * Instead, an explicit, final `return` statement is placed for you. * 2. No Scanner operations should appear here (e.g., input.nextInt()). * Instead, refer to the input parameters of this method. * 3. Do not re-assign any of the parameter/input variables. */ // Your implementation of this method starts here.

// Do not modify this return statement. return result; }

the unit tests:

/* * Tests related to Task 2 */ @Test public void test_task2_01() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {1, 2, 3, 4, 5}; assertArrayEquals(expected, Utilities.task2(seq, 0)); } @Test public void test_task2_02() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {5, 1, 2, 3, 4}; assertArrayEquals(expected, Utilities.task2(seq, 1)); } @Test public void test_task2_03() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {2, 3, 4, 5, 1}; assertArrayEquals(expected, Utilities.task2(seq, 4)); } @Test public void test_task2_04() { int[] seq = {1, 2, 3, 4, 5}; int[] expected = {3, 4, 5, 1, 2}; assertArrayEquals(expected, Utilities.task2(seq, 8)); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!