} // [lp] output: an array of doubles b. // [4p] Gets an array that starts...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
} // [lp] output: an array of doubles "b". // [4p] Gets an array that starts at a[m] and stops at a[n], and also includes all of the elements in between (in their original order). In other words, this function returns the input array "a", but only from index "m" up to (and including) index "n". // HINT: The length of the output array "b" is n m + 1. // Erase this line and put your fromTo() subroutine here. // // // indexOfMax() // // [lp] input an array of doubles. // [1p] output: an integer. // [6p] Returns the INDEX of the maximal element of an array. // Erase this line and put your indexOfMax() subroutine here. // swap() // // [3p] input: two integers "m" and "n", and an array of doubles "a". // [lp] output: an array of doubles "a". // // [4p] Interchanges the elements a[m] and a[n], so that a[m] is where a[n] // used to be, and a[n] is where a[m] used to be. // HINT: You will need to define a temporary variable in order to // interchange the two elements of the array. // Erase this line and put your swap() subroutine here. import java.util.Arrays; public class FinalExam { // main() // [2p] Creates an array of five random doubles between 0 and 10. // [2p] Prints the array to standard output (HINT: use Arrays.toString()). // [2p] Sorts the array using the selectionSort() function below. // [2p] Prints the sorted array to standard output. // Erase this line and put your main() subroutine here. // selectionSort() // [1p] input an array of doubles "a". // [1p] output: an array of doubles "a". // // // [6p] Uses the functions fromTo(), indexOfMax(), and swap() to execute a Selection Sort, in which the largest element is repeatedly moved to the end of the array, and the largest index under consideration is reduced by one. // // // HINT: You may consult section 7.4.4 in our textbook, but do not simply // copy the code from that section. Your implementation of selectionSort() // must call the functions fromTo(), indexOfMax(), and swap() to receive // points. // Erase this line and put your selectionSort() subroutine here. // fromTo() // [3p] input: two integers "m" and "n", and an array of doubles "a". // [1p] output: an array of doubles "b"." // } // [lp] output: an array of doubles "b". // [4p] Gets an array that starts at a[m] and stops at a[n], and also includes all of the elements in between (in their original order). In other words, this function returns the input array "a", but only from index "m" up to (and including) index "n". // HINT: The length of the output array "b" is n m + 1. // Erase this line and put your fromTo() subroutine here. // // // indexOfMax() // // [lp] input an array of doubles. // [1p] output: an integer. // [6p] Returns the INDEX of the maximal element of an array. // Erase this line and put your indexOfMax() subroutine here. // swap() // // [3p] input: two integers "m" and "n", and an array of doubles "a". // [lp] output: an array of doubles "a". // // [4p] Interchanges the elements a[m] and a[n], so that a[m] is where a[n] // used to be, and a[n] is where a[m] used to be. // HINT: You will need to define a temporary variable in order to // interchange the two elements of the array. // Erase this line and put your swap() subroutine here. } // [lp] output: an array of doubles "b". // [4p] Gets an array that starts at a[m] and stops at a[n], and also includes all of the elements in between (in their original order). In other words, this function returns the input array "a", but only from index "m" up to (and including) index "n". // HINT: The length of the output array "b" is n m + 1. // Erase this line and put your fromTo() subroutine here. // // // indexOfMax() // // [lp] input an array of doubles. // [1p] output: an integer. // [6p] Returns the INDEX of the maximal element of an array. // Erase this line and put your indexOfMax() subroutine here. // swap() // // [3p] input: two integers "m" and "n", and an array of doubles "a". // [lp] output: an array of doubles "a". // // [4p] Interchanges the elements a[m] and a[n], so that a[m] is where a[n] // used to be, and a[n] is where a[m] used to be. // HINT: You will need to define a temporary variable in order to // interchange the two elements of the array. // Erase this line and put your swap() subroutine here. import java.util.Arrays; public class FinalExam { // main() // [2p] Creates an array of five random doubles between 0 and 10. // [2p] Prints the array to standard output (HINT: use Arrays.toString()). // [2p] Sorts the array using the selectionSort() function below. // [2p] Prints the sorted array to standard output. // Erase this line and put your main() subroutine here. // selectionSort() // [1p] input an array of doubles "a". // [1p] output: an array of doubles "a". // // // [6p] Uses the functions fromTo(), indexOfMax(), and swap() to execute a Selection Sort, in which the largest element is repeatedly moved to the end of the array, and the largest index under consideration is reduced by one. // // // HINT: You may consult section 7.4.4 in our textbook, but do not simply // copy the code from that section. Your implementation of selectionSort() // must call the functions fromTo(), indexOfMax(), and swap() to receive // points. // Erase this line and put your selectionSort() subroutine here. // fromTo() // [3p] input: two integers "m" and "n", and an array of doubles "a". // [1p] output: an array of doubles "b"." // import java.util.Arrays; public class FinalExam { // main() // [2p] Creates an array of five random doubles between 0 and 10. // [2p] Prints the array to standard output (HINT: use Arrays.toString()). // [2p] Sorts the array using the selectionSort() function below. // [2p] Prints the sorted array to standard output. // Erase this line and put your main() subroutine here. // selectionSort() // [1p] input an array of doubles "a". // [1p] output: an array of doubles "a". // // // [6p] Uses the functions fromTo(), indexOfMax(), and swap() to execute a Selection Sort, in which the largest element is repeatedly moved to the end of the array, and the largest index under consideration is reduced by one. // // // HINT: You may consult section 7.4.4 in our textbook, but do not simply // copy the code from that section. Your implementation of selectionSort() // must call the functions fromTo(), indexOfMax(), and swap() to receive // points. // Erase this line and put your selectionSort() subroutine here. // fromTo() // [3p] input: two integers "m" and "n", and an array of doubles "a". // [1p] output: an array of doubles "b"." //
Expert Answer:
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Lucy has just been promoted to a managerial position and given a new office. She is very fond of small Persian carpets and Native American paintings and wants to get some carpets and paintings for...
-
On January 2, 2016, Smythe Co. paid $255,000 for a computer system. In addition to the basic purchase price, the company paid a setup fee of $1,500, sales tax of $6,600, and $31,900 for a special...
-
Temptation Food Products Ltd is an established processed foods company specialising in latest packaged and branded foods. The following particulars about its capital structure and other parameters...
-
What are the two purposes of taking a deposition?
-
A demonstration gyroscope wheel is constructed by removing the tire from a bicycle wheel 0.650 m in diameter, wrapping lead wire around the rim, and taping it in place. The shaft projects 0.200 m at...
-
A company has the following data. Annual fee = 50/customer Avg spending per customer = 500/month 1% commission earned on customer spending Annual maintenance cost = 250M/year variable cost =...
-
Consider the Everglade cash flow problem discussed in this chapter. Suppose that extra cash is kept in an interest-bearing savings account. Assume that any cash left at the end of a year earns 3...
-
Snort is a very powerful intrusion detection software system. For Project 2, you are required to install and run Snort on your home computer and home network. The details of the task are as follows....
-
What are the different dimensions of organizational justice (e.g., distributive, procedural, interactional), and how do they each contribute to overall employee satisfaction and retention?
-
Which value chain is an inventoriable product cost or a period cost. Explain your justification construction cost. Technology costs. Labor expenses. Investment in machinery and tools. Restoration and...
-
Show that 23 2 3 -1 A=110 is singular matrix 12 -3 5
-
Juniper Design, provides design services to residential developers. Last year, the company had net operating income of $420,000 on sales of $1,200,000. The company's average operating assets were...
-
Three point charges, q1 = -4:07nC, q2 = 4.97nC and q3 = 2.64nC are aligned along the x axis as shown in the figure below. Assume that L = L L2 -X 9 92 93 Calculate the electric field at the position...
-
1) What is the difference between random sampling andrandom assignment? Random sampling and random assginment are basically the samething. Random assignment applies to how the observational units...
-
During 2012, Cheng Book Store paid $483,000 for land and built a store in Georgetown. Prior to construction, the city of Georgetown charged Cheng $1,300 for a building permit, which Cheng paid. Cheng...
-
Do we have our priorities in order? We trust our school aged children to be taught by dedicated teachers in our schools, but we pay those teachers only about $50,000 per year. At the same time, we...
-
Since the early 1970s, the U.S. government has had a program called the Earned Income Tax Credit (previously mentioned in end-of-chapter exercises in Chapter 3.) A simplified version of this program...
-
A: Suppose the production process for a firm is homothetic and has decreasing returns to scale. (a) On a graph with labor on the horizontal and capital k on the vertical axis, draw an isoquant...
-
Three brothers, Daniel, David and Derrick have been discussing their respective taxation affairs and how much they dislike paying tax. None of them are Scottish taxpayers. Daniel's income for tax...
-
Roseanne is a Scottish taxpayer. She starts trading on 1 July 2023 and prepares accounts for the 16 months to 31 October 2024. The adjusted trading profit for this period is 38,560. Her only other...
-
You are a trainee chartered certified accountant and your manager has asked you for your help with regard to a taxpayer who has made trading losses. Sean has been in self-employment since 2011, but...
Study smarter with the SolutionInn App