Question: 2 Learning Objectives 1. Use the Integer wrapper class. 2. Declare and use ArrayList class objects 3. Write code to read from, and write to,

 2 Learning Objectives 1. Use the Integer wrapper class. 2. Declare

and use ArrayList class objects 3. Write code to read from, and

write to, text files 4. Write an exception handler for an I/Oexception 5. Write Java classes and instantiate objects of those classes 3

Background Let list be a nonempty sequence of nonnegative random integers, each

2 Learning Objectives 1. Use the Integer wrapper class. 2. Declare and use ArrayList class objects 3. Write code to read from, and write to, text files 4. Write an exception handler for an I/O exception 5. Write Java classes and instantiate objects of those classes 3 Background Let list be a nonempty sequence of nonnegative random integers, each in the range [0, 32767] and let n be the length of list, e.g. list 2, 8, 3, 2, 9, 8, 6, 3, 4, 6, 1, 9 ) where n - 12. List elements are numbered starting at 0. We define a run up to be a (k+1)-length subsequence starting at index i: list. list, 1, list, .2, , list, k, that is monotonically increasing (i.e.. list,.. 1st, for each J-1, 2, 3, , k). Similarly, a run down is a (k+1)-length subsequence starting at index i: listi, list,-i, list,i2, ..., listuk, that is monotoni- cally decreasing (i.e., list,ti S listu for each j-1, 2, 3, ..., k). For the above example list we have these runs up and runs down: Runs Up list, through list = { 2, 8 }; k= 1, 2-length subseq list,-{ 2 }; k = 0, 1-length subseq list-{ 3 }; k= 0, 1-length subseq lists through list 2, 9 ; k-1, 2-length subseq list through list 9, 8, 6, 3 ; k 3, 4-length subseq lists- 8 k0, 1-length subseq list, { 6 }; k 0, 1-length subseq list, through list, { 3. 4. 6 }; k= 2, 3-1en subseq listi,-{ 9 }; k = 0, 1-length subseq listo through listi-11, 9 1; k-1, 2-len subseq Runs Down lish through list,-{ 8, 3, 2 }; k 2, 3-length subseq lists { 4 }; k 0, l-length subseq list through listo 6, 1 ; k-1, 2-length subseq We are interested in the value of k for each run up and run down and in particular we are interested in the total number of runs for each nonzero k, which we shall denote by runi. O list -new ArrayList

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!