Describe an approach to modifying the program

Assignment Help Basic Computer Science
Reference no: EM131229269

In Exercise 1 you were asked to modify the Sor t s program so that it would output the number of swaps used by a sorting method. It is a little more difficult to have the program also output the number of comparisons needed. You must include one or more statements to increment your counter within the sorting methods themselves. For each of the listed methods, make and test the changes needed, and list the number of comparisons needed by Sor t s to sort an array of 50 random integers.

2143_1fc6ef7f-cb6e-4c65-8f41-547b35e77287.png

Exercise 1

A test harness program for testing sorting methods is provided with the rest of the textbook program files. It is in the file Sor t s . j a va in the c h10 package. The program includes a s wa p method that is used by all of the sorting methods to swap array elements.

a. Describe an approach to modifying the program so that after calling a sorting method the program prints out the number of swaps needed by the sorting method.

b. Implement your approach.

c. Test your new program by running the s e l e c t i onSor t method. Your program should report 49 swaps

Reference no: EM131229269

Questions Cloud

What is an example of a situation : What is an example of a situation (preferably in a business context) in which you have had to choose between "right" and "wrong"?
How you plan to get the word out : Who your audience is/will be. (What is your area like? Are there a lot of theatre goers to attract or areyou going to have to sell the idea of going to theatre in addition to selling the production?)
How do you interpret the weights for the two assets : FNCE5008 Financial Principles and Analysis What is the expected return on a portfolio that is equally invested in the two assets (share and risk free asset) and If a portfolio of the two assets has a beta of 0.8, what are the portfolio weights for th..
Determine the overall impact of the product : a. Determine the overall impact of the product launch on your company. For example, how will this launch impact your other products on themarket? How will this launch impact your overall net income?
Describe an approach to modifying the program : A test harness program for testing sorting methods is provided with the rest of the textbook program files. It is in the file Sor t s . j a va in the c h10 package. The program includes a s wa p method that is used by all of the sorting methods to..
How does the social concept of race relate to each group : How has U.S. society used each group's culture to construct the group identity? How has each group been stereotyped? How accurate are these stereotypes? How does the social concept of race relate to each group? What prejudice has each group faced?
Find the index of hourly compensation costs for workers : Find the index of hourly compensation costs for workers in manufacturing at the Bureau of Labor Statistics website. Over the 1990-1999 period, compare costs in the U.S. to those in Canada.
Production facility before making purchase decisions : Potential customers frequently visit your production facility before making purchase decisions. You and the people who report to you in the sales department have received extensive training in etiquette issues because you deal with high-profile clien..
Web server-application server : Define and describe the following: web server, application server, and multitiered client or server architecture.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write a function that reverses the order of the items

Implement the function swap, as described in Checkpoint Question 3, but remove the assumption that the i th and jth items on the list exist. Return a value that indicates whether the swap was successful.

  Create a method to make each object in the first list

Create a method to make each object in the first list say hello to each object in the second list, and vice versa.

  Determine a formula that counts the numbers of nodes

Determine a formula that counts the numbers of nodes in the recursion tree. What is Big- O for execution time? Determine a formula that expresses the height of the tree. What is the Big-O for memory?

  United states consumer product safety commission website

Visit the United States Consumer Product Safety Commission website. Click on "Recalls." Choose one product that has been recalled. Describe the product subject to recall, including the recall date, recall number, and the reason for the recall.

  Writing java program which can develop anagrams

An anagram is a rearrangement of the letters of a word or phrase into a new word or phrase. Some of them can be quite amusing or apt. For example:

  How long would it take to get a standard error of 0.0001

Give an expression for how long it would take to be 95% sure that the error is less than 1E - 4.

  Interactive java program that asks a user for some interest

Create an interactive Java program that asks a user for some text of interest and then displays the first email address found in that text. (This is the basis for one of the programs that spammers use to mine text, such as email messages, Web pages, ..

  What is difference between attributes and elements in xml

difference between attributes and elements in XML

  How long should this information be kept

If this information could be used to help you establish an alibi, would you want the cell phone company to be able to release it to the police?

  Explaining binary normalization shift-and-subtract

Convert input arguments to binary. Binary normalization shift-and-subtract.

  Dynamic programming

Please provide with a detailed answer using DYNAMIC PROGRAMMING

  Draw a block diagram of the realization with an integrator

A student has computed det C = 2.3 × 10 -7 and claims that the system is uncontrollable. Is the student right or wrong? Why?

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