Write a method called removeEvens that removes the values in evennumbered indexes from a list, returning a

Question:

Write a method called removeEvens that removes the values in evennumbered indexes from a list, returning a new list that contains those values in their original order. For example, consider a variable list1 that stores the values [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 may not call any methods of the class other than the constructor to solve this problem. You may not create any new nodes nor change the values stored in data fields to solve this problem. You must solve it by rearranging the links of the list.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Building Java Programs A Back To Basics Approach

ISBN: 9780135471944

5th Edition

Authors: Stuart Reges, Marty Stepp

Question Posted: