Alpha Geek

(8)

$10/per page/Negotiable

About Alpha Geek

Levels Tought:
University

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Environmental science,Essay writing,Programming,Social Science,Statistics Hide all
Teaching Since: Apr 2017
Last Sign in: 438 Weeks Ago, 6 Days Ago
Questions Answered: 9562
Tutorials Posted: 9559

Education

  • bachelor in business administration
    Polytechnic State University Sanluis
    Jan-2006 - Nov-2010

  • CPA
    Polytechnic State University
    Jan-2012 - Nov-2016

Experience

  • Professor
    Harvard Square Academy (HS2)
    Mar-2012 - Present

Category > Computer Science Posted 05 May 2017 My Price 7.00

Describe an approach to modifying the program

 

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.

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

 

 

 
 

Answers

(8)
Status NEW Posted 05 May 2017 12:05 PM My Price 7.00

-----------

Attachments

file 1493987074-Answer.docx preview (367 words )
I-----------n E-----------xer-----------cis-----------e 1----------- yo-----------u w-----------ere----------- as-----------ked----------- to----------- mo-----------dif-----------y t-----------he -----------Sor----------- t -----------s p-----------rog-----------ram----------- so----------- th-----------at -----------it -----------wou-----------ld -----------out-----------put----------- th-----------e n-----------umb-----------er -----------of -----------swa-----------ps -----------use-----------d b-----------y a----------- so-----------rti-----------ng -----------met-----------hod-----------. I-----------t i-----------s a----------- li-----------ttl-----------e m-----------ore----------- di-----------ffi-----------cul-----------t t-----------o h-----------ave----------- th-----------e p-----------rog-----------ram----------- al-----------so -----------out-----------put----------- th-----------e n-----------umb-----------er -----------of -----------com-----------par-----------iso-----------ns -----------nee-----------ded-----------. Y-----------ou -----------mus-----------t i-----------ncl-----------ude----------- on-----------e o-----------r m-----------ore----------- st-----------ate-----------men-----------ts -----------to -----------inc-----------rem-----------ent----------- yo-----------ur -----------cou-----------nte-----------r w-----------ith-----------in -----------the----------- so-----------rti-----------ng -----------met-----------hod-----------s t-----------hem-----------sel-----------ves-----------. F-----------or -----------eac-----------h o-----------f t-----------he -----------lis-----------ted----------- me-----------tho-----------ds,----------- ma-----------ke -----------and----------- te-----------st -----------the----------- ch-----------ang-----------es -----------nee-----------ded-----------, a-----------nd -----------lis-----------t t-----------he -----------num-----------ber----------- of----------- co-----------mpa-----------ris-----------ons-----------
Not Rated(0)