Question: Write a method removeEvens that removes the values in even-numbered indexes from the list, returning a new list that contains those values in their original

Write a method removeEvens that removes the values in even-numbered indexes from the list, returning a new list that contains those values in their original order.

For example, consider a variable 'list1' that stores the following sequence of values.

list1 = [8, 13, 17, 4, 9, 12, 98, 41, 7, 23, 0, 92]

and imagine that the following call is made:

LinkedIntList list2 = list1.removeEvens();

After the call, list1 should store [13, 4, 12, 41, 23, 92] and list2 should store [8, 17, 9, 98, 7, 0]

*You are not allowed to create any new nodes nor change the values stored in data fields. You must solve the problem by rearranging the links of the list.

Plz help! This is a test problem from Java data structure class.

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!