} // [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
-
Problem 9. (1 point) A single population hypothesis test was conducted on a normally distributed numeric variable, where the population standard deviation was known. The test statistic was calculated...
-
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...
-
Does there exist a 3 à 3 symmetric matrix with eigenvalues λ1 = -1, λ2 = 3, λ3 = 7 and corresponding eigenvectors If so, find such a matrix; if not,...
-
2-3: Determine the yield strength-to-density ratios (specific strength) in units of kN m/kg for AISI 1018 CD steel, 2011-T6 aluminum, Ti-6Al-4V titanium alloy, and ASTM No. 40 gray cast iron. 2-4:...
-
The 2015 annual report of The Procter & Gamble Company (P&G) is available at www.pginvestor.com. After reviewing P&Gs annual report, respond to the following questions: a. P&Gs net income and net...
-
John Davis owns Eastcoasters, a bicycle shop in Millersville. Most of Johns bicycle sales are customer orders; however, he also stocks bicycles for walk-in customers. He stocks three types of...
-
The Riteway Ad Agency provides cars for its sales staff. In the past, the company has always purchased its cars from a dealer and then sold the cars after three years of use. The company's present...
-
After the success of the company's first two months, Santana Rey continues to operate Business Solutions. (Transactions for the first two months are described in the Chapter 2 serial problem.) The...
-
Please have a look at these website for the rules while writing the answers http://dbs211.ca/ Normalization 1. For the following User view, please identify the UNF (3 Marks): ENGLISH AS SECOND...
-
A 2.50 g sample of copper (Cs copper = 0.385 J/(g C)) that had been heated to 200. C was placed in a flexible container with an initial volume of 1.5 L and an initial temperature of 25 C that was...
-
Ana and Pedro work in a company that offers continuous training in order to continue developing employees' skills. They also have a program where coworkers vote among themselves to recognize...
-
SHERIDAN Company Comparative Balance Sheets December 31 Assets 2022 2021 Cash $72,900 $32,600 Accounts receivable 85,800 71,300 Inventory 170,100 186,800 Land 73,700 100,200 Equipment 259,700 200,200...
-
A force F = (4.07xi + 2.91y j)N, where x and y are in metres, acts on an object as it moves in the x direction from the origin to x = 5.18m. Calculate the work done on the object by the force. Submit...
-
How the uC/OS-II real time kernel measures the utilization of a CPU when multiple tasks are running? what is the initialization steps that are performed? and any assumptions made (if any) what are...
-
The following information is for zero-coupon bonds with $1,000 maturity value. Maturity (years) Bond Price (S) 970 940 910 1 3 a) Derive the yield curve that is consistent with the above data. b)...
-
Define cultural intelligence. Cite the books or journal articles you found in Capella's library. Explain why cultural intelligence is important for HR practitioners and other organizational managers.
-
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...
-
The safety and soundness of the financial system relies to a large extent on the action of the central banks. Explain this statement and illustrate the ways in which central banks improve safety and...
-
The CAMELS system is a popular list for regulators. Explain what it is and its importance.
-
The Basel Accords have had a great impact on the banking industry. Describe these and explain their significance to the ordinary person.
Study smarter with the SolutionInn App