mptions: sea may be empty. indices may be empty. indices' may contain duplicates. to return? or each integer value in indices`, if it is a valid index for in then use it to index into sea' and include the result in the ou example: Say ssa is (23, 46, 69} and 'indices is (2, -1, 0, 3. (where indices -1 and 3 are invalid, so only indices 2, 0, 0, 2 a Then the method should return (69, 23, 23, 69}

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
Input Parameters:
sea: an array of integers
indices': an array of integers (each of which may or may not be a valid index for sea")
Assumptions:
sea may be empty.
indices may be empty.
*indices may contain duplicates.
What to return?
- For each integer value in 'indices', if it is a valid index for input array ssa',
then use it to index into 'sea' and include the result in the output array.
For example: Say ssa' is (23, 46, 69} and indices' is (2, -1, 0, 3, 0, 2}
(where indices -1 and 3 are invalid, so only indices 2, 0, 0, 2 are used)
Then the method should return (69, 23, 23, 69}
Note: Order of elements in the output array corresponds to the order in which
valid indices in the 'indices' array are arranged.
That is, the output array may be empty if the input array sea is empty,
or if the input array indices does not contain any valid indices.
See the JUnit tests related to this method.
*/
public static int () task1(int ) seq, int () indices) {
int (] result - null;
return result;
Transcribed Image Text:Input Parameters: sea: an array of integers indices': an array of integers (each of which may or may not be a valid index for sea") Assumptions: sea may be empty. indices may be empty. *indices may contain duplicates. What to return? - For each integer value in 'indices', if it is a valid index for input array ssa', then use it to index into 'sea' and include the result in the output array. For example: Say ssa' is (23, 46, 69} and indices' is (2, -1, 0, 3, 0, 2} (where indices -1 and 3 are invalid, so only indices 2, 0, 0, 2 are used) Then the method should return (69, 23, 23, 69} Note: Order of elements in the output array corresponds to the order in which valid indices in the 'indices' array are arranged. That is, the output array may be empty if the input array sea is empty, or if the input array indices does not contain any valid indices. See the JUnit tests related to this method. */ public static int () task1(int ) seq, int () indices) { int (] result - null; return result;
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Binary Search Algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,