Create an array of size n and fill it

Assignment Help JAVA Programming
Reference no: EM13240349

As a new and eager employee of Ti.18Tech, Inc. you've been asked by your employer to implement a sorting algorithm for inclusion in a package for a lucrative client. However, your boss just wants you to implement one of the simple, quadratic sorting algorithms. To prove that this would be a big mistake, you've decided (on your own) to prove to your idiot boss that it's worth the extra effort to implement one of the O(n log n) sorting algorithms. For this project, you will implement and compare five sorting algorithms: bubble sort, insertion sort, selection sort, quicksort, and either mergesort or shellsort. Your main program will then do the following:

1. Ask the user for the size n of the list he/she wants to sort.

2. Create an array of size n and fill it with random integers between 1 and n. If n<=100, display the random ?array on the screen.

3. Run each of your sorts on this array. You must make a deep copy of the array before sorting it, or your ?second sort will have an easy time of it. Use the System.currentTimeMillis() function to determine the ?running time of each sort.

4. If n<=100, display the sorted arrays on the screen (they better be the same!).

5. Display the time each sort used to sort the array.

Once you have your program working, use it to plot a graph. Have the x-axis represent n, and the y-axis the running time. Use n=10000, 20000, ..., 100000. Plot all sorting algorithms on the same graph (use different colors or line styles). You shall use a spreadsheet program (e.g., MS Excel) or some other program to do this for you. (Will your boss be convinced?)

Notes

1. Before you begin programming, sketch a high level design of what you want to implement using the UML notation. At the very least, you should have a use case diagram, class diagram and a sequence diagram.

2. Remember to include comments at the top of your program and 1-2 lines for each function (including pre- and post-conditions). Use javadoccompatible comments.

3. The System.currentTimeMillis() function will return the current system time in milliseconds. Make a call before and after running a sort, then subtract to get the elapsed time. You may need to cast it to type int using (int) System.currentTimeMillis().

4. Use the compareTo() function of the built-in Comparable interface to compare objects in the array, and store your numbers using the built-in Integer wrapper class.

5. Use a random number generator to fill the array.

Reference no: EM13240349

Questions Cloud

Calculate the net change in the entropy : imagine that you spill a cup (250 g) hot water, initially at 75 C, onto the cold ground on a winter fay, Calculate the net change in the entropy of the universe due to this process, and comment on the result
What should i do in the future replication study : This question has to do with power. Suppose in a clinical study you have two groups with 10 subjcects in each group. No significance at the .05 level is found but there is a medium effect size, which is judged to be of practical significance. What sh..
Compute the vapor pressure of water : Calculate the vapor pressure of water, in torr, above a solution prepared by dissolving 65.40 g of ZnCl2 in 445.0 g of water at 323.0 K. The vapor pressure of pure water at 323.0 K is 92.50 torr.
Does dichotomizing the dependent variable logistic regressio : Does dichotomizing the dependent variable (i.e. logistic regression) decrease power in relation to a continuous dependent variable?
Create an array of size n and fill it : Sketch a high level design of what you want to implement using the UML notation. At the very least, you should have a use case diagram, class diagram and a sequence diagram.
Find the x-component of the electric field ex : A point charge of 20nC is placed on the x-axis at the point x = 2. Find the x-component of the electric field Ex at x = 4 and x = -1 where the coordinates are in meters
What are nonnormal error terms : The table on page 124 indicates XRAY was the only variable input into the equation and the model’s overall percentage correct was 75.47%. On page 125, STAGE was entered into the equation, but it looks like the model still correctly classified 75.47%...
Display the structure for the major product : Draw the structure for the major product formed when cyclohexanone reacts with each of the following- hydrazine, then hot, fused KOH
American influence-manifest destiny in western hemisphere : What does the article fit into your understanding of American influence and manifest destiny in the Western hemisphere?

Reviews

Write a Review

JAVA Programming Questions & Answers

  How to access to elements of document object model

To limit creation of malicious code, do you believe that access to elements of document object model and some Javascript functionality be limited?

  Writing a simple gui application using a class called myguic

writing a simple GUI application using a class called MyGuiClass. Your GUI will have a JButton which your program will need to respond to when it is clicked. Describe what you would need to do to setup event handling using a nested inner class. Use J..

  Create a java program to calculate the circumference

Create a Java program based on the geometric shapes. The program should begin by prompting you for the shape you want to calculate the circumference.

  Write a program that reads in a text file and then computes

Write a program that reads in a text file and then computes and prints a table of letter frequencies. For example, if the file is the text of "A Tale of Two Cities", found in the file at data/tales.txt , the program will print

  Write a method in java that uses a switch statement

Write a method in JAVA that uses a switch statement and takes a person's age using an integer parameter , then checks if the age is valid (0-110), and then RETURNS a string based on the age

  Write a java program that declares an array alpha of 50

Write a Java program that declares an array alpha of 50 elements of type double. Initialize the array so that the first 25 elements are equal to the square of the index variable, and the last 25 elements are equal to three times the index variable. O..

  Create four classes

Create four classes: Account.java, Checking.java, Savings.java, and AccountArray.java.

  Given an array with 100,000 entries to sort

Sorting  given an array with 100,000 entries to sort. Under what circumstances would you use each of the following: insertion sort,mergesort'quicksort

  Write a java program that will read a sequence of names

Write a java program that will read a sequence of names (first name followed by last name, separated by at least one space) from a text file and will 1) remove all duplicate names and 2) write the names (last name followed by a comma, followed by one..

  Create dict letter frequencies that reads the file

createDictLetterFrequencies that reads the file and also takes a parameter n. This method should return a dictionary of dictionaries. The outer dictionary associates the previous n letters of a word with an inner dictionary, which indicates the frequ..

  Insert uml design diagrams, use case, classes

Insert UML design diagrams here (use case, class, and sequence diagram).

  Write a method called hash midpoint

Write a method called hasMidpoint that accepts three integers as parameters and returns 'true' if one of the integers is the midpoint between the other two integers; that is to is if one integer is exactly between the two others. The method should re..

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