Q1) Structured Insertion Sort Your program should be called StrInSort.java and it should define a single...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Q1) Structured Insertion Sort Your program should be called StrInSort.java and it should define a single class, StrInSort. It's main method will consider one argument, the name of a file containing your input data. Input data should be positive integers separated by spaces. Your goal is to take a "structuring pass" over the data before performing a regular insertion sort. Your structuring pass will look for runs, starting from the beginning of the array and moving left to right. Whenever you find a run in this manner that is in DESCENDING order you should reverse it. Keep track of how many times you reverse values in this fashion. Also keep track of any runs in ASCENDING order of length 2. When you go to sort your data, make sure you sort it in DESCENDING order. Take a look at the example output on the next page to see how to present your results and note what things you have to look out for while writing your code. DebugRunner can be pretty picky, so you want to make sure you're pretty close. Don't do wasteful swaps or compares. Use the same names in your own output. Note the use of singular tense when outputting results about a single occurrence of something. These are just small programming details, but I want to remind you to keep an eye out for details. Q2) Theory: Qualify This Structuring How did the structuring pass you performed, specifically the reversals chosen, affect swaps and com- parisons? Was anything else affected? Answer in less than 100 words. Q3) Theory: Size of Runs How do you feel the size of the specific runs you recorded (ASCENDING order of length 2) impacted performance? Answer in less than 100 words. Q4) Theory: Doubly Linked Lists What would implementing this as a Doubly Linked List do? How would the specified structuring affect results? Answer in less than 100 words. Structured Insertion Sort Example You might type: java StrInSort inputs 1.txt inputs1.txt might look like: 88 89 4 63 6 67 55 55 73 19 95 35 41 22 50 33 37 94 48 33 25 72 22 87 1 The output would look something like: 88 89 4 63 6 67 55 55 73 19 95 35 41 22 50 33 37 94 48 33 25 72 22 87 1 We sorted in DESC order We counted 6 ASC runs of length 2 We performed 3 reversals of runs in DESC order We performed 24 compares during structuring We performed 175 compares overall We performed 132 swaps overall 95 94 89 88 87 73 72 67 63 55 55 50 48 41 37 35 33 33 25 22 22 19 6 4 1 Q1) Structured Insertion Sort Your program should be called StrInSort.java and it should define a single class, StrInSort. It's main method will consider one argument, the name of a file containing your input data. Input data should be positive integers separated by spaces. Your goal is to take a "structuring pass" over the data before performing a regular insertion sort. Your structuring pass will look for runs, starting from the beginning of the array and moving left to right. Whenever you find a run in this manner that is in DESCENDING order you should reverse it. Keep track of how many times you reverse values in this fashion. Also keep track of any runs in ASCENDING order of length 2. When you go to sort your data, make sure you sort it in DESCENDING order. Take a look at the example output on the next page to see how to present your results and note what things you have to look out for while writing your code. DebugRunner can be pretty picky, so you want to make sure you're pretty close. Don't do wasteful swaps or compares. Use the same names in your own output. Note the use of singular tense when outputting results about a single occurrence of something. These are just small programming details, but I want to remind you to keep an eye out for details. Q2) Theory: Qualify This Structuring How did the structuring pass you performed, specifically the reversals chosen, affect swaps and com- parisons? Was anything else affected? Answer in less than 100 words. Q3) Theory: Size of Runs How do you feel the size of the specific runs you recorded (ASCENDING order of length 2) impacted performance? Answer in less than 100 words. Q4) Theory: Doubly Linked Lists What would implementing this as a Doubly Linked List do? How would the specified structuring affect results? Answer in less than 100 words. Structured Insertion Sort Example You might type: java StrInSort inputs 1.txt inputs1.txt might look like: 88 89 4 63 6 67 55 55 73 19 95 35 41 22 50 33 37 94 48 33 25 72 22 87 1 The output would look something like: 88 89 4 63 6 67 55 55 73 19 95 35 41 22 50 33 37 94 48 33 25 72 22 87 1 We sorted in DESC order We counted 6 ASC runs of length 2 We performed 3 reversals of runs in DESC order We performed 24 compares during structuring We performed 175 compares overall We performed 132 swaps overall 95 94 89 88 87 73 72 67 63 55 55 50 48 41 37 35 33 33 25 22 22 19 6 4 1
Expert Answer:
Answer rating: 100% (QA)
Heres a Java implementation for the Structured Insertion Sort java import javaioBufferedReader import javaioFileReader import javaioIOException public ... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
Skip to main content Lab 11: A Web Server The goal of this lab is to write a simple, but functional, web server that is capable of sending files to a web browser on request. The web server must...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Evaluate the limit or determine that it does not exist. |xx| lim (x,y)(0,0) [x] + [yl
-
The preliminary 2018 income statement of Alexian Systems, Inc., is presented below: ___________________________________ALEXIAN SYSTEMS, INC. _______________________________________Income Statement...
-
Microlenders are institutions that lend relatively small amounts of money to businesses. An article on microlenders compared the average return on equity for lenders of two categories based on their...
-
Chang Koh Metal Ptd. Ltd. was founded in Singapore in 1982 by Teo Kai San, a first generation Straits-born Chinese. The companys operations were in the production of metal-stamping precision parts....
-
A biological fluid moves at a flow rate of m = 0.02 kg/s through a coiled, thin-walled, 5-mm-diameter tube submerged in a large water bath maintained at 50C. The fluid enters the tube at 25C. (a)...
-
1. discuss the broad problem you intend to research; share what the client thinks about the issue and detail whether and how you may be able to accurately clarify and state the problem you intend to...
-
Bob Burley and his brother Buford ran the best restaurant in Dallas, Texas. Many out-of-towners would visit Dallas and go to Burleys Biscuits, Beef, and Veggies for a good wholesome meal. One thing...
-
Suppose Dean has $500 and there are two companies he could invest X dollars in: Dog Gone Salon, which has a payoff of 2X with 50% probability and $0 with 50% probability and Pretty Kitty Grooming,...
-
1. All of the following terms represent the same concept, except: a. Table b. Entity d. Relation C. Information 2. The process of finding a good strategy for processing a query is called? a. Query...
-
Provide a sufficient explanation of what transpired over this period (starting from initial investment to quarter 1, quarter 2, and quarter 3) for each company and then for the overall portfolio, how...
-
8. Shane and Barry live in the same house and share the washing and cooking dulies around the house. Shane can either prepare four meals or do 16 washes, and Barry can either prepare 16 meals or do...
-
Question 1 Outline one argument for and one argument against the use of project management. Question 2 Describe the difference between the initiation and the plan phases of the project lifecycle. Use...
-
Two identical curling stones of mass 19.5 kg collide. The stone m1 is moving at 5.00 m/s to the right towards a stationary stone of mass m2. The collision is a glancing collision. After the...
-
Which of the following questions could NOT be answered as a result of organizational behavior research findings? a. What goal level will best motivate my employees? b. How important is employee...
-
suppose a nickel-contaminated soil 15 cm deep contained 800 mg/kg Ni, Vegetation was planted to remove the nickel by phytoremediation. The above-ground plant parts average 1% Ni on a dry-weight bas...
-
This problem investigates D. Willard's "y-fast tries" which, like van Emde Boas trees, perform each of the operations MEMBER, MINIMUM, MAXIMUM, PREDECESSOR, and SUCCESSOR on elements drawn from a...
-
Modify the proto-vEB structure to support duplicate keys.
-
This problem examines three algorithms for searching for a value x in an unsorted array A consisting of n elements. Consider the following randomized strategy: pick a random index i into A. If A[i] =...
-
On April 20, 1992, Daniel Hubbard (plaintiff), a potato farmer, and UTZ Quality Foods, Inc. (UTZ) (defendant), a potato chip manufacturer, entered an installment contract under which Hubbard agreed...
-
Plaintiff purchases a new car that has defects in its paint job. Three times the dealership repaints the care, but to no avail. The plaintiff continues to drive the car as he has no other option in...
-
Plaintiff contracted to install a boiler for defendant. After plaintiff had installed and tested the boiler, but before final payment to plaintiff had been made, defendant took custody of the boiler...
Study smarter with the SolutionInn App