Demonstrate how the quicksort algorithm behaves

Assignment Help JAVA Programming
Reference no: EM13552234

The purpose of this program is to demonstrate how the quicksort algorithm behaves. You will be implementing quicksort, but in a way that allows the program's user to visually observe how the algorithm proceeds by watching animated colored bars.

Two base classes (DoubleCell and SortGUI) are provided to assist with the basics of animation. You should not alter these classes, but write a Driver class that uses the provided classes to implement a proper quicksort.

The SortGUI class provides a GUI that implements buttons for the user to start and stop a sort animation, as well as buttons to reset the sort data in either random, ascending or descending order. These data are displayed for the user as rectangular bars on a JFrame. Programmatically, your code accesses each bar by virtue of a doubly-linked list. The form of a list cell is defined by the DoubleCell interface. You will need to use the methods of DoubleCell to manipulate the list. Also, the list includes sentinel cells at both ends. The getAnchor() and getBackAnchor() methods from SortGUI provide access to the anchors, that in turn link to the sentinel cells.

SortGUI interacts with your Driver class in two ways. Firstly, SortGUI calls a Driver method, named initializeSort() every time that the user chooses a new set of data. Your Driver needs to implement initializeSort() as a public parameterless void method that performs whatever function that you find necessary to reset for a new sort. The second obligatory method in Driver is called sortNext(). This method is called repeatedly by SortGUI to accomplish a sort. In other words SortGUI uses a Timer object to generate timed events. Each timed event results in another call to sortNext(). Your task is to cause each sortNext() call to perform one more step of the sort. One step would be something like selecting the next pivot or advancing the lower pointer of the pivot range by one or advancing the upper range pointer by one position or swapping two values within the pivot range. At all times your code should keep the current pivot bar colored in red and the two range bars colored green so the user can better follow the animation.

Your sortNext() method is also responsible for terminating the sort at the proper time. A stopSorting() method is included in SortGUI for your code to call when it is time to end the animation.

Write a second complete program that implements the merge sort algorithm in the same way. That is this program must provide a good step-by-step animation of merge sort using SortGUI and DoubleCell.

Reference no: EM13552234

Questions Cloud

Evaluate how far below the water can she swim : The human lungs can function satisfactorily up to a limit where the pressure difference between the outside and inside of the lungs is 1/21 of an atmosphere. how far below the water can she swim
An earthquake generates three kinds of waves : An earthquake generates three kinds of waves: surface waves (L waves), which are the slowest and weakest; shear (S) waves, which are transverse waves and carry most of the energy; and pressure (P) waves, which are longitudinal waves and travel the..
Calculate the speed an alpha particle : Find the speed an alpha particle requires to come within 2.6 × 10^?14 m of a gold nucleus. Coulomb's constant is 8.99 × 10^9 N · m2/C2
Solid sphere rolling without slipping on a rough horizontal : A solid sphere rolling without slipping on a rough horizontal surface with a linear speed 21m/s collides elastically with a fixed, smooth vertical wall. Find the speed of the solid sphere after it has started pure rolling in the backward direction. T..
Demonstrate how the quicksort algorithm behaves : Demonstrate how the quicksort algorithm behaves. You will be implementing quicksort, but in a way that allows the program's user to visually observe how the algorithm proceeds by watching animated colored bars.
Evaluate the volume in liters occupied by carbon monoxide : Calculate the volume in liters occupied by carbon monoxide in a room that measures 12.67 m long, 14.87 m wide, and 16.96m high at this concentration.
Calculate actual velocity of rain : A man is stationary and he observes that the rain is striking him at 60? from the horizantal. When he starts moving with a velocity of 25 m/s, then he observes that the rain strikes him at an angle of 30? from the horizantal. Calculate actual velo..
Reduce the liability of foreignness : Which geographic diversification is most likely to reduce the liability of foreignness?
What force would the water exert on the vehicles : The Mariana trench is located in the Pacific Ocean at a depth of about 11 000 m below the surface of the water. If an underwater vehicle were to explore such a depth, what force would the water exert on the vehicle's observation window

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program to read a file and encode

Write a program to read a file and encode the file to an encrypted file. And write a program to get an encrypted file and decode to original file. Your program should prompt the user to enter an input file name and an output file name

  Application for an animal-fur trimming service

Create an application for an animal-fur trimming service. Write the code for the application. Prompt the user to indicate how many animals. Display the total fee for one year. Be pleasant in your output as it will be expensive.

  Create a world class that contains a 2d array

You have to create a world class that contains a 2d array then create an abstract class called organism that contains move() method the organism should move randomly one step at the time.

  Write an application to calculate the salespersons salary

Write an application that prompts the user to enter the sales for each employee, then it calculates the salesperson's salary. The process repeats until the user finishes entering all employees' information.

  Document the current application describing major classes

Add to the Project Management tool the different planned activities needed to implement the changes to the solution and document the current application describing the major classes used by the application.

  Reads contents of two vectors

Write a program that reads contents of two vectors, and then displays the sum of these two vectors. The program should prompt the user to enter the size of the vectors first.

  Shooting star

Initial project folder you will see the beginnings of a Driver - You need to implement that DoubleListOfBlock methods so they perform

  Java program by array

Write a program that reads in a file that contains one integer per line. Each integer represents one location in the image. Assume that there are 64 rows and 64 columns in the image

  Write the logical expression in postfix notation.

Given symbols p, q, r, and s for propositions. Draw the binary tree representation of the logical expression ((p || r) && ! p ) || s) && (q || r). Write the logical expression in postfix notation.

  Create a secure parts inventory catalog system

You will create a secure Parts Inventory Catalog system using Model 2 architecture. The application will require a user to have the proper access right to enter the system, and when satisfied, presents the catalog of items currently available in t..

  Alicia creates a button using the code jbutton exit button

Alicia creates a button using the code JButton exitButton = new JButton("exit"); and places it into a JFrame named mainFrame

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

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