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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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