Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2.2.3 Method to Implement: get Interlevaings Problem. You are asked to implement a utility method which takes as inputs the first terms (/1, 82), common
2.2.3 Method to Implement: get Interlevaings Problem. You are asked to implement a utility method which takes as inputs the first terms (/1, 82), common differences (dl, d2), and sizes (nl, and n2) of two arithmetic sequences. The utility method should return a string valuc containing a new sequence interleaving items drawn from the two arithmetic sequences. The interleaving starts from an item drawn from the first sequence, if it is not empty. For example, consider two arithmetic sequences with the same length: (3, 8) and (11, 4). Their interleaving is then (3, 11, 8, 4), where the Ist and 3rd items are drawn from the first arithmetic sequence, and the 2nd and 4th items are drawn from the second arithmetic sequence. In general, your implementation of the utility method should consider when the two arithmetic sequences are of different lengths (in which case the last items in the interleaving should be drawn from the longer arithmetic sequence). Requirement. It is strictly forbidden for you to use arrays or any library class (e.g., ArrayList). Violating this requirement will cause a 50% penalty on your lab marks. Testing. Your goal is to pass all tests related to this method in the JUnit test class TestUtilities. These tests document the expected values on various cases: study them while developing your code. However, use the console application class GetInterleavings App if you wish (e.g., use the input and expected values from the JUnit tests). Here are two example runs: Enter the first integer term of arithmetic sequence 1: 3 Enter the common difference of the sequence: 5 Enter the size of the sequence: 2 Enter the first integer term of arithmetic sequence 2: 11 Enter the common difference of the sequence: -7 Enter the size of the sequence: 2 Enter the first integer term of arithmetic sequence 1: 3 Enter the common difference of the sequence: 5 Enter the size of the sequence: 1 Enter the first integer term of arithmetic sequence 2: 11 Enter the common difference of the sequence: -7 Enter the size of the sequence: 3 Todo. Implement the Utilities.get Interlevaings mcthod. Soc the comments there for the input parameters and requirements. The String return value inust conform to the expected format: . All interlea items shoul wrapped within angle brackets (o) and separated by commas (,). Ther onc space after each comma. is Items drawing from the first arithmetic sequence should be wrapped within round parentheses (eg.. (3)). Items drawing from the second arithmetic sequence should be wrapped within square brackets (c.g., [11]). 9
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