Invokes the selection sort algorithm to sort them

Assignment Help Data Structure & Algorithms
Reference no: EM131299322

Polymorphic Sorting

In this exercise, you will use the Sorting class to sort several different types of objects.

1. The file Numbers.java reads in an array of integers, invokes the selection sort algorithm to sort them, and then prints the sorted array. Save Sorting.java and Numbers.java to your directory. Numbers.java won't compile in its current form. Study it to see if you can figure out why.

2. Try to compile Numbers.java and see what the error message is. The problem involves the difference between primitive data and objects. Change the program so it will work correctly (note: you don't need to make many changes the autoboxing feature of Java 1.5 will take care of most conversions from int to Integer).

3. Write a program Strings.java, similar to Numbers.java, that reads in an array of String objects and sorts them. You may just copy and edit Numbers.java.

4. Modify the insertionSort algorithm so that it sorts in descending order rather than ascending order.

Change Numbers.java and Strings.java to call insertionSort rather than selectionSort. Run both to make sure the sorting is correct.

5. The file Salesperson.java partially defines a class that represents a sales person. This is very similar to the Contact class in Listing 9.10. However, a sales person has a first name, last name, and a total number of sales (an int) rather than a first name, last name, and phone number. Complete the compareTo method in the Salesperson class. The comparison should be based on total sales; that is, return a negative number if the executing object has total sales less than the other object and return a positive number if the sales are greater. Use the name of the sales person to break a tie (alphabetical order).

6. The file WeeklyS ales .java contains a driver for testing the compareTo method and the sorting. Compile and run it. Make sure your compareTo method is correct.

The sales staff should be listed in order of sales from most to least with the four people having the same number of sales in reverse alphabetical order.

Reference no: EM131299322

Questions Cloud

Define a competitive equilibirum for this economy : ECON 3102-004 Intermediate Macroeconomics Assignment. Define a Competitive Equilibirum for this economy. Characterize the CE with a system of 9 equations. Clearly state what variables can be pinned down and which cannot
Create the report for the given case study : Given is the Case Study topic is : "Murphy Manufacturing".- Prepare a complete and comprehensive report for Joe to use for his two o'clock meeting.
Direct and indirect effects of an increase : What are the direct and indirect effects of an increase in the money supply? What are the effects of a tariff on a good?
Pursuing a fixed exchange rate regime : Assume that policy makers are pursuing a fixed exchange rate regime. Now suppose that the foreign interest rate increases. Discuss what policy makers must do to maintain the pegged exchange rate. Also discuss what effect this will have on domestic..
Invokes the selection sort algorithm to sort them : The file Numbers.java reads in an array of integers, invokes the selection sort algorithm to sort them, and then prints the sorted array. Save Sorting.java and Numbers.java to your directory.
Equation for the marginal revenue : a. Write down the equation for the marginal revenue b. How many copies of the book would maximize the company's profits? c. What would the profit-maximizing price be? d. How much profit would the company make?
Performance of workers in all the company’s jobs : Does the reason for the policy change involve the reliability, the bias, or the validity of IQ tests as a measure of future job performance? Explain your answer.
Participate in this discussion by explaining : Participate in this discussion by explaining in what ways the firm that owns and operates the Rialto, Colony, and Studio movie theaters appears to be involved in monopolistic competition.
Identify possible sources of suspicious numbers : Are any of the numbers suspect? Why? You might look at the questions in the EESEE story to help you identify possible sources of suspicious numbers.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd