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

  Develop a raptor flowchart to compute the solution

Develop a Raptor flowchart to compute the solution of the equation

  What are the basic steps and components

What are the basic steps and components needed to evaluate submitted proposals?

  Five assumptions of free market capitalism

List and describe at least five assumptions of free market capitalism.

  Write java program convert sorted array into balanced tree

Balanced Search Tree Write a program (in Java) that can convert a sorted array into a balanced binary search tree. For this project, a balanced binary tree is one where the size of the left and right subtrees at each node differs by at most one.

  Determine the maximum mass of the log

Assume that the engine of the truck is powerful enough to generate a torque that will cause all the wheels to slip.

  Develop a make-change program

The program should be written in MIPS. Develop a Make-Change program

  What purposes do views serve

What is the limitation on SELECT statements used in SQL views?

  Show that fractional error of this scheme is at most 1/2p

We can modify the algorithm of Section 23.5.2 to use buckets whose sizes are powers of 2, but there are between p and p + 1 buckets of each size, for a chosen integer p > 1. As before, sizes do not decrease as we go further back in time.

  Distinguish between two incoming requests

How does a firewall distinguish between two incoming requests allowing one while denying the other.

  Collaboration and social media

While planning for a new project, a young developer mentions that she used Facebook as a collaborative group space for developing her senior project. She tells you that it was the ideal solution since it was free and all of her group members were ..

  Question-internet service provider

Question:  Internet Service Provider An Internet service provider has three different subscription packages for its customers: Package A: $9.95 per month for 10 hours access. Additional hours are $2.00 per hour

  What is the advantage of having user page tables in virtual

In the VAX, user page tables are located at virtual addresses in the system space. What is the advantage of having user page tables in virtual rather than main memory? What is the disadvantage?

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