Bubble sort, insertion sort, selection sort

Assignment Help Basic Computer Science
Reference no: EM13934479

As a new and eager employee of Google Tech; 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?)

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).

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.

6. Hint: Use the sample Sorts.java file from the textbook. (provided)

Reference no: EM13934479

Questions Cloud

The annual profits from this new piece of equipment : The Central Clinic, a local not for profit health center, is considering investing $5,000 today in a new piece of screening equipment. The annual profits from this new piece of equipment will be $800 for each of the seven years of its useful life. Wh..
Evidence on the global burden of depression : The burden of depression: Citing existing evidence on the global burden of depression from lectures 1 and 2, describe why thinking of depression makes sense in this scenario.
Use the concept of you get what you measurer in your answer : Use the concept of You get what you measurer in your answer.
Loan out all of funds you receive from sale of your stock : Martin and Sons (M and S) currently is an all equity firm with 64,000 shares of stock outstanding at a market price of $25 a share. The company's earnings before interest and taxes are $86,000. How many of your shares of stock in M and S must you sel..
Bubble sort, insertion sort, selection sort : As a new and eager employee of Google Tech; you've been asked by your employer to implement a sorting algorithm for inclusion in a package for a lucrative client.
How can electrolyte imbalance control our heart function : Electrolyte balance is very important in our body. This balance can even greatly influence our heart functions - causing arrhythmia or even a heart attack. Lets discuss this situation - how can electrolyte imbalance control our heart function?
Explain the output employment wage and income distributional : Using the diagram below explain the output, employment, wage, and income distributional consequences of an increase in migration of labour = L1US - L2US from Mexico to the USA.
Core principles that underlie your approach to leadership : What are the core principles that underlie your approach to leadership and in light of the ideas presented in this course, how you will lead in the future?
Program to print a business travel expenses : Write a program to print a business travel expenses attachment for an income tax return.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What is the difference between text i/o and binary i/o

What is the difference between text I/O and binary I/O?

  Creating the walburg energy alternatives database

Complete In The Lab 2 - Creating the Walburg Energy Alternatives Database - on page AC 68 - AC 69 at the end of Access Chapter 1. Perform all steps. Submit the entire database file for grading.

  Contrast theories of absolute and comparative advatages

Compare and contrast theories of absolute and comparative advatages. Explain Porter's "Diamond" model of national competitive advantage. Briefly describe some of the main instruments of trade policy that countries use to interfere with free trade.

  Representing negative numbers

what the rule is for determining which bit is the sign bit. Try and test your theory to be sure. See if you can prove and/or disprove it. Write down your theory of how the sign bit is indicated

  How do providing goods and services for government differ

How do providing goods and services for the government differ from providing goods and services for other organizations?

  Database distribution strategy/simple database application

For this assignment, you will design and develop a distributed database infrastructure for an organization of your choice. You may use the database you created in another unit or you may choose to create a new database to work with for this assign..

  A subclass of an abstract class does not provide implement

f a subclass of an abstract class does not provide implementation code for all the abstract methods of its superclass, it too becomes an _______

  Class structure with its instance fields and methods

What are the advantages of the Java object class structure with its instance fields and methods?

  Department of management information systems

Identify the benefits of using e-learning from the perspective of students of the first level in the Department of Management information systems.

  Create a list of the top-five utilities computer should have

Create a list of the top-five utilities you feel every computer should have. For each utility, discuss whether it is included in the OS and/or if there are alternatives that can be downloaded for free or that can be purchased as stand-alone progra..

  Word-processing drawing tools

For drawings, you may use your word-processing drawing tools, graphic applications, or scanned hand drawings and insert them in the main document.  Create a zip file containing your document and source code files.  Show all of your work.

  What personal leadership characteristics

What personal leadership characteristics are most important, for building successful buying or selling teams? Could you please answer them around 200 words?

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