View the step-by-step solution to:

Question

I hope you are doing well today.

I am not exactly sure where to start here, except I have a main

class and inserted the code to instantiate the ArrayList variable list. It asks for multiple methods but I am not sure what methods to invoke. 

I guess I also have no idea what "runs" are or how to use them. I understand monotonically increasing and decreasing sets but I don't understand the significance of the k variable or any of the notation. This makes it hard for me to build an algorithm.  I have also never seen them used in code before so I have no idea what calls to make. 

Since this is an intermediate level computer science class, I would appreciate it if you refrain from using more advanced classes and java tools. 

Thank you.

CSE205 Object Oriented Programming and Data Structures Programming Project 1 :: 25 pts 1 Submission Instructions Create a folder named < asuriteid> where asuriteid is your ASURITE user id (for example, since my ASURITE user id is kburger2 my folder would be named kburger2 ) and copy all of your .java source code files to this folder. Do not copy the .class files or any other files. Next, compress the <asuriteid> folder creating a zip archive file named < asuriteid>.zip (mine would be named kburger2.zip ). Upload < asuriteid>.zip to the Project 1 dropbox by the project deadline. The deadline is 11:59pm Fri 28 Mar. Consult the online syllabus for the late and academic integrity policies. 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 list i , list i +1 , list i +2 , . .., list i + k , that is monotonically increasing (i.e., list i + j list i + j -1 for each j = 1, 2, 3, . .., k ). Similarly, a run down is a ( k +1) - length subsequence list i , list i +1 , list i +2 , . .., list i + k , that is monotonically decreasing (i.e., list i + j -1 list i + j for each j = 1, 2, 3, . .., k ). For the above example list we have these runs up and runs down: Runs Up list 0 through list 1 = { 2, 8 }; k = 1 list 2 = { 3 }; k = 0 list 3 through list 4 = { 2, 9 }; k = 1 list 5 = { 8 }; k = 0 list 6 = { 6 }; k = 0 list 7 through list 9 = { 3, 4, 6 }; k = 2 list 10 through list 11 = { 1, 9 }; k = 1 Runs Down list 0 = { 2 }; k = 0 list 1 through list 3 = { 8, 3, 2 }; k = 2 list 4 through list 7 = { 9, 8, 6, 3 }; k = 3 list 8 = { 4 }; k = 0 list 9 through list 10 = { 6, 1 }; k = 1 list 11 = { 9 }; k = 0 We are interested in the value of k for each run up and run down and in particular we are interested in the total umber of runs for each nonzero k, which we shall denote by runs k , 0 < k < n - 1. For the example list we have: k runs k runs 1 4 { 2, 8 }, { 2, 9 }, { 1, 9 }, and { 6, 1 } 2 2 { 3, 4, 6, } and { 8, 3, 2 } 3 1 { 9, 8, 6, 3 } 4-11 0 Let runs total be the the sum from k = 1 to n - 1 of runs k . For the example list , runs total = 4 + 2 + 1 = 7. Arizona State University Page 1 link in the course schedule
Background image of page 1
CSE205 Object Oriented Programming and Data Structures Programming Project 1 :: 25 pts 4 Software Requirements Your program shall: 1. Open a file named p01-in.txt containing n integers, 1 n 1000, with each integer in [0, 32767]. There will be one or more integers per line. A sample input file: Sample p01-in.txt 2 8 3 2 9 8 6 3 4 6 1 9 2. The program shall compute runs k for k = 1, 2, 3, . .., n - 1. 3. The program shall compute runs total . 4. The program shall produce an output file named p01-runs.txt containing runs total and runs k for k = 1, 2, 3, . .., n - 1. The file shall be formatted as shown in the example file below. Sample p01-runs.txt runs_total, 7 runs_1, 4 runs_2, 2 runs_3, 1 runs_4, 0 runs_5, 0 runs_6, 0 5. If the input file p01-in.txt cannot be opened for reading (because it does not exist) then display an error message on the output window and immediately terminate the program, e.g., run program. .. Sorry, could not open 'p01-in.txt' for reading. Stopping. 5 Software Design Your program shall: 1. Contain a class named Main . This class shall contain the main () method. The main () method shall instantiate an object of the Main class and call run () on that object. // Main.java public class Main { public static void main(String[] pArgs) { Main mainObject = new Main(); mainObject.run() } private void run() { // You will start writing code here to implement the software requirements. } } 2. One of the primary objectives of this programming project is to learn to use the java.util.ArrayList class. Therefore, you are not permitted to use 1D arrays. Besides, you will quickly discover that the ArrayList class is more convenient to use than 1D arrays. Arizona State University Page 2
Background image of page 2
Show entire document

Top Answer

View the full answer
code.zip - Preview not available

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online