Section6Problems 4 - 11 Write value removes all that a...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 11. Write value. removes all that a method removeAll For example, if the list contains of a particular occurrences values: the folfowing 13, 9, 4, 2, 3, 8, L1, 4, 3, 181 The method call: Iist. removeALl (3) ; alL occurrences of the value 3 from the current list, woul-d remove yielding: 19, 4, 2, 8, !7, 4, 181 at aII, doesn't appear in the list then your method. You must preserve the If the list is empty or thre value the Iist shoul-d not be changed by order of the Iist orj-ginal L2. Write and that as a parameter a method equal-s that takes a second List false returns true if the two lists returns otherwise. are equal and that Two lists are considered equal if they store exactJ-y the same values in the same order and have exactfy exactly the same length. 9,lrite a method positions from For new Iist. listl: Then the 13. in even-numbered removeBvens that removes the values order returning in their original a lj-st, those values stores these values: example if a variable call"ed list1 13, Ll, call: as a [8, 4, 9, L2, 98, 4I, 1, 23, 0, 92] f ol-Iowinq LinkedfntList Shoul-d resu.l-t listl: list2: in Iist2 listl and Iistl. list2 removeEvens O ; storing the following values: [13, 4, [8, I7, 12, 4I, 23, 92] 9, 98, 7, 0] were original-1y in List2 are the values that Notice that stored the values (index 0, index 2, index 4r'and positions so on) and that in even-valued Also notice list. as in the original these values appear in the same order values in listl appear in the same order as in the left also that the Iist. original returns LinkedlntList has a zero-argument constructor that Recall that an Y ou m ay n ot c a-lf- a ny m ethods-of,-tshe t ha+-Ehe c lass-sther empty l ist problem. You are not al-Iowed to create any new to solve this constructor in data fiel-ds to sofve thi-s problem. stored nodes or to change the values You MUST soLve it by rearranging the Links of the list. ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online