Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a main method Write a method called extractOddIndexes that constructs and returns a new List of values that contains the sequence formed by removing
Write a main method
Write a method called extractOddIndexes that constructs and returns a new List of values that contains the sequence formed by removing the values at odd indexes in an existing List of values. For example, suppose that a List called list1 stores the following sequence of values: list1 = [13, 5, 7, 12, 42, 8, 23, 31] If we make the following call on the method: List result = extractOddIndexes (list1); After the call, list1 and result would store the following: listi : [13, 7, 42, 23] result : [5, 12, 8, 31] Notice that the values that were at odd indexes have been moved to the new List in the same order as in the original list and that the list now stores just values that were at even indexes also in the same order as in the original list. The list might have an odd number of values, as in: list2 = [14, -64, 16, 88, 21, 17, -93, 81, 17] in which case the lists would store the following after the call: list2 : (14, 16, 21, -93, 17] result : [-64, 88, 17, 81] Notice that list stores five values while result stores only four. ListStep 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