Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 5 (20 pts.) File SortByLength.java given below contains an incomplete program The goal of the program is to read a text file into an

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Task 5 (20 pts.) File SortByLength.java given below contains an incomplete program The goal of the program is to read a text file into an array list of strings, and then sort that list, so that the strings appear in ascending order of their length. Complete that program, by defining a sortByLength function, that satisfies the following specs: Function sortByLength takes one argument, called input_list, that is an array list of strings. The function should return an array list called result with length equal to the length of A. The result should contain the same elements as A, but in ascending order of their length. IMPORTANT: You are NOT allowed to modify in any way the main function. You are free to define and use auxiliary functions. Hint: my solution also includes (and uses) the insertBeforeLonger function from the previous task. My solution takes five lines of code, in addition to the insertBeforeLonger function. This is an example run of the program, using input file fmlin1.txt Please enter the name of the input file: fmlinl.txt Input: [whale, cat, elephant, donkey, goat] Output: [cat, goat, whale, donkey, elephant] This is an example run of the program, using input file fmlin2.txt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Draw molecular diagram for the following molecules C2H4 Co CN NH3

Answered: 1 week ago