Question: This problem will explore some basic traits of an unsorted list of data. We will not go to the extent of sorting the data, but

This problem will explore some basic traits of an unsorted list of data. We will not go to the extent of sorting the data, but try to understand some ideas leading to sorting. Write a class, UnsortedData, that has two "public static" methods

o A method "countOutOfPosition" that takes as parameter and array of doubles, and returns a count of how far "out of position" all the items are. Do this by summing up (for each item "i" in the array) how many items after item"" in the unsorted list are smaller than item "i".

o A method "bubble" that takes as parameter and array of doubles, and performs the following operation once on every item in the unsorted list

If an item is larger than the item after it, swap the items

Write a UnsortedData App program, that prompts the user for a name of an input file, then reads 100 real numbers from the file, You can assume the file exists, and contains 100 valid real numbers. Then call "countOutOfPosition" and display the result. Then call "bubble" and your first function again and see if there items are not as far "out of position" as before. Here is a sample run

What is the name of the input file? dataRandom.txt

Total Out of Order BEFORE Bubble2604

Total Out of Order AFTER Bubble2508

For the first problem, the txt file it should read is https://blackboard.iit.edu/bbcswebdav/pid-589727-dt-content-rid-7988616_1/xid-7988616_1 which looks like,

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 Programming Questions!