List the algorithm and the big o notation

Assignment Help JAVA Programming
Reference no: EM133389676

1. The time required in nanoseconds, the number of comparisons required and the time to execute a basic step (the comparison) in ns for each of the sort methods provided. The basic step is determined by taking the time required to sort an array of a size n and dividing by the number of comparisons required for that algorithm. Report your results for data sets of 30, 300, 30000 elements.

2. Modify the sorta, sortb, sortc, sortd, sorte methods to count the number of comparisons and return this value from the method. Suggested Steps:
a. Change each of the sort methods from type void to type int.
b. Add a local count variable to each method.
c. Increment the count just before the comparison of two array elements in each of the sort methods.
d. Return the count value from the method and print to the screen in the main method.

3. The sorta method currently counts the # of comparisons by using a global variable. This is not a good programming technique. Modify the sorta method to count comparisons by passing a parameter. This is a little trickier as the comparisons are done in the part method. You should notice that the number of comparisons can be determined before the call to the part method. You will need to return this value from
the sorta method and modify the sorta header to pass this value into each recursive call. You will need to add the counts recursively. As an alternative to the recursive counting, you can leave the code as is and complete the sorta counting using the global variable.

4. Adding counting to the sortd method. Again, you can use a recursive technique or use a global variable. Recursive counting is preferred. If this is not possible use a global variable like sorta

5. Time the java standard Arrays.sort method for all three sizes.

6. In a Comment section at the TOP of your source file, provide answers to the following:
o Identify the type of sorts for each of the methods provided. Indicate which sort (a,b,c,d,e) is bubble, quick, merge, selection or insertion.
o List in order (fastest to slowest) your selection of algorithm to use when the array to be sorted contains 30 elements. Base this on your results
o List in order (fastest to slowest) your selection of algorithm to use when the array to be sorted contains 30000 elements.
o List the algorithm and the BIG O notation (time complexity, average case) for that algorithm. Does the Big O notation line up with your results for 30000 elements?
o Which algorithm has the best performance of the basic step? Does this have any impact on your selection of fastest algorithm when sorting an array of 30000 elements? Why?
o For the standard Arrays.sort method, which algorithm do the performance results most resemble.1. The time required in nanoseconds, the number of comparisons required and the time to execute a basic step (the comparison) in ns for each of the sort methods provided. The basic step is determined by taking the time required to sort an array of a size n and dividing by the number of comparisons required for that algorithm. Report your results for data sets of 30, 300, 30000 elements.

2. Modify the sorta, sortb, sortc, sortd, sorte methods to count the number of comparisons and return this value from the method. Suggested Steps:
a. Change each of the sort methods from type void to type int.
b. Add a local count variable to each method.
c. Increment the count just before the comparison of two array elements in each of the sort methods.
d. Return the count value from the method and print to the screen in the main method.
3. The sorta method currently counts the # of comparisons by using a global variable. This is not a good programming technique. Modify the sorta method to count comparisons by passing a parameter. This is a little trickier as the comparisons are done in the part method. You should notice that the number of comparisons can be determined before the call to the part method. You will need to return this value from
the sorta method and modify the sorta header to pass this value into each recursive call. You will need to add the counts recursively. As an alternative to the recursive counting, you can leave the code as is and complete the sorta counting using the global variable.

4. Adding counting to the sortd method. Again, you can use a recursive technique or use a global variable. Recursive counting is preferred. If this is not possible use a global variable like sorta

5. Time the java standard Arrays.sort method for all three sizes.

6. In a Comment section at the TOP of your source file, provide answers to the following:
o Identify the type of sorts for each of the methods provided. Indicate which sort (a,b,c,d,e) is bubble, quick, merge, selection or insertion.
o List in order (fastest to slowest) your selection of algorithm to use when the array to be sorted contains 30 elements. Base this on your results
o List in order (fastest to slowest) your selection of algorithm to use when the array to be sorted contains 30000 elements.
o List the algorithm and the BIG O notation (time complexity, average case) for that algorithm. Does the Big O notation line up with your results for 30000 elements?

o Which algorithm has the best performance of the basic step? Does this have any impact on your selection of fastest algorithm when sorting an array of 30000 elements? Why?
o For the standard Arrays.sort method, which algorithm do the performance results most resemble.

Reference no: EM133389676

Questions Cloud

How was the middle class enticed to enter theaters : What city is the focus of this article and what time period does it cover? What was appealing about saloons to workers? (list as many factors as you can.)
What are the implications for using the code coverage ratio : What are the implications for using the code coverage ratio as an adequacy criterion? (Mutation-based testing)
Calculate the product of a series of integers : Calculate the product of a series of integers that are passed to method product using a variable-length argument list. Test your method with several calls
Analyze if the use of atomic weapons to defeat : Assess if the United States foreign policy during the 1930s helped to promote World War II. Could the United States have prevented the outbreak of World War II?
List the algorithm and the big o notation : List the algorithm and the BIG O notation (time complexity, average case) for that algorithm. Does the Big O notation line up with your results for 30000
How did the abolishment of slavery pave the way for groups : How did The Abolishment of slavery pave the way for groups such as "Black Power" "Blank Panthers" and Black Lives Matter Movement ?
Avoid blunders in international marketing : List the globally useful ways of segmenting according to customer categorization. List a few do's and don'ts to avoid blunders in international marketing.
What were the different progressive views about world war i : What were the different progressive views about World War I (WWI)? What did competing progressive perspectives about U.S. involvement in World War I
Write a program that prompts the user for a measurement : Write a program that prompts the user for a measurement in meters and then converts it to miles, feet, and inches.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a driver class that uses the computermicrobe class

You must create two Java files. One is called LastNameFirstNameWeek7Prog.java, and the other is called ComputerMicrobe.java.

  Write a program that draws a diamond shape

Write a program that draws a diamond shape according to the number you read as seen below. The program will readone int value (lineCount).

  A program that reads a four-digit number from the keyboard

Write a program that reads a four-digit number from the keyboard as a string and then converts it into decimal. For example, if the input is 1100, the output should be 12. Hint: Break the string into characters and then convert each character to a va..

  Find the equilibrium levels of exchange rate

a) In the initial long-run equilibrium, the government collects 15% of long-run output as taxes and runs a budget deficit of 400, while the central bank sets th

  Design and implement a rmi-based client

In this assignment, you are requested to build a system which allows a school pupil to practise multiple choice tests in math. Design and implement a RMI-based Client / Server communication system in Java, which will do the following:

  Evidence at a pre trial admissibility hearing

The prosecution believes that Ella stole 1.5 million dollars from her previous employer but Ella claims she didn't. At the pre trial admissibility hearing I wou

  In light of wrestling with ethics

In light of "Wrestling With Ethics" and other research/articles that you are able to draw upon, should profitability drive social responsibility? Be sure to support your discussion question responses with evidence from the readings and/or additional ..

  Create an array of date objects

Create an array of Date objects of size 4. Initialize the array by using a loop. In the loop, use the Scanner.nextLine() method to input a date as a string, convert it to a date by using the toDate() method, and assign the result to an element in ..

  Create an application using html5

Create an application using HTML5, CSS, and JavaScript that has an image or figure of a trashcan

  Despite public and private health insurance programs

Why is it that despite public and private health insurance programs, some US citizens are without health coverage?

  Write a method named promptstring in java

The Star Wars universe is a world based on a series of movies from the 70s and then later the late-90s and early-00s.

  Design and game loop with all the dummy functions

Design and game loop with all the dummy functions. During this module, implement one of the very first steps of Tetris, "Display the Bucket".

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