Question
Recursive program to nd largest/smallest elements in an ArrayList: Write a program that reads a data le of doubles into an ArrayList and prints the
Recursive program to nd largest/smallest elements in an ArrayList: Write a program that reads a data le of doubles into an ArrayList and prints the elements and the number of items read in. 1. The name of the data le should be provided interactively. Do Not hard code the name of the data le. 2. Write a recursive function that returns the largest and smallest elements in the ArrayList and the corresponding indices. To return these four items, you need to return an object that is an instance of an inner class called MinMaxObject that you will dene to contain four private variables max, min, maxPos, minPos of types double, double, int and int respectively.
Use dataset Lab4.dat to test your program. You should use appropriate Java features including the Scanner class for reading in data, ArrayList of Doubles, enhanced for loop, etc.
Demonstration of Towers of Hanoi:
You do not need to do any coding for this part. Rather, you will use the coded solution for the Towers of Hanoi problem. The code includes graphical display of the algorithm at work. 1. Log in to your linux.ens account and copy the directory Towers and all its contents from the directory ~class_//. 2. Compile the code and run the applet either by using applet viewer or a browser. You may need to slow down (nd out how!) the code so you can see the disks move. You should read the code in TowersApp.java to understand the recursive problem solving used. All labs and programs that you turn in should include your name, student ID, and lab section.
The numbers are below in Lab.dat
23.2 12.12 -6.43 18.0 91.6 74.2 100.87 61.0 13.76
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started