This preview shows page 1. Sign up to view the full content.
Unformatted text preview: o. Write a method mirror that doubles the size of a List of integers appending the mirror image of the original sequence to the end of The mirror image is the same sequence of values in reverse order. if example, a variable called list stores Lhis seguence of values: [1, 3, 2, 7] following call: by the 1ist. For and we make the list.mirror then it
[1, () ; the
2, shouLd store
3, 2,'7, 7t fol-lowing
3, 1] values after the call: it has been doubled in size by having the original Notice that sequence in reverse order at the end of the list. You may not make appearing about how many elements are in the list assumptions 7. Write a method stretch that takes an integer n as a parameter and that increases a list by a factor of n by replacing in of integers each integer list with n of that integer. For example, if the original a variable called Iist stores this sequence of values: [18, 7, 4, 24, 11] call: and we make the following Iist. The list
[18, 8. stretch (3) ; shoul-d store
18, 18, 7, the
7, J, following
1, 4, 4t values
24, 24, after
24, the method is
11, 11, 11] called: that Write a method longestSortedSequence sequence within a Iist of integers. sorted list called stores the following sequence [1r then the 1ist. 3r 5r 2r 9r 7, -3r 0, 42r 308, returns the length of the Iongest For example, if a variable of values: L7] call: longestSortedSequence () 4 because it would return is the length sorted the value of the longest (the sequence -3, 0, 42, 308) . is list If the list sequence within this Notice for a non-empty list the 0. that empty, your method should return a value of at Ieast 1 because any individual method will always return a sorted sequence. element constitutes ...
View Full Document
This note was uploaded on 11/03/2009 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.
- Spring '08