Section6Problems 5

# Section6Problems 5 - L4 list removes a section a method...

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ,/ ./ L4. list removes a section a method removeRange that of a linked of Write We will of referring to the f i-rst use the Java convention integers. 0, the second having position as having position 1 and elemenL of the list To call removeRaogâ‚¬, you must specify ds in: two positions, so on. lst. removeRange (3, 8) ; 8 values 3 and This requests the removal of all- val-ues between positions For example, tf the list had contained the following inclusive. before this caII: [8, the are 13, LJ, 4, 9, 12, 98, 4t,'7, 23, 0, 92] and position list: 8 (the values between position 3 (the value 4) you with the following removed, leaving [8, L3, LJ, 23, 0, 92) value '7) You should throw an IllegalArgumentException you may assume that the negat.ive. Otherwise (0 range of the list 15. if ej-ther positions of the positions represent a legal is doubles the size of a list Write a method doubleT,ist that by appending sequence to the end of the Iist. For example, if copy of the original sequence of values: variabfe called Iist stores this a a IL, and we 3, 2, make 11 following call: the l-ist. then it , doubLel.j'st O ; should 3, 2, store 1, L, the 3, 2, followinq 7] in size by having the original sequence values after the call: it has been doubled Notice that two times in a row. appearing about how many elements are in the Iist. You You may not make assumptions problem. If the may not call any methods of the class to solve this n nodes, then you shoul-d construct list contains exactly n nodes original You may not use any auxiliary data structures to to be added to the list. (no array, problem queue, String, Arraylist, etc) . Your stack, this solve list. method shoufd run in O(n) time where n is the number of nodes in'the ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online