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

  Redesign the grading program as an object-oriented design

redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles)

  Java-s ability to derive new fonts from existing ones

Find out where on your system these font libraries are located. When you do, please specify the operating system and the location (folder/directory) where you found them. Discuss Java's ability to derive new fonts from existing ones.

  Bilinear and nearest neighbour algorithm in java

How to do bilinear and nearest neighbour algorithm in java. Show how to eliminate change in pixel aspect ratio in java.

  Design a solution to the problem by using the five steps to

the software needs to allow the restaurant owner to schedule employees for up to 40 hours in a seven-day week. the

  Once getting into student information menu

Once getting into student information menu, you should be able to see a full list of students' information (first name, last name, SSN, DOB, year and major).

  Construct the student class student.h

Construct the Student Class Student.h and Student.cpp student class should include a Student.h header file for your class definitions and a Student.cpp implementation file comprised of first name, last name, ram id

  Write a method to save a linked list to a text file

Write a method to save a Linked List to a text file called file.txt. It must save the Linked List to the file with each node on a different line.

  Write following java expressions in mathematical notation

Write the following Java expressions in mathematical notation.

  Explain the legal doctrine benefits balancing

Explain the legal doctrine "Benefits Balancing" as it pertains to applying the reasonable standard of care doctrine in the medical fields. Does a defense that the majority of physicians normally do not give a particular diagnostic test in the normal ..

  Write a class named test scores

Write a class named TestScores.The class constructor should accept an array of test scores as an argument.The class should have a method that returns the average of the test scores.

  Client class to test implementation of the vector class

Write a client class to test your implementation of the Vector3D class thatyou implemented. Name the package in which this class is defined (projectname) vector3dapp.

  Program to find maximum-minimum of sequence of values

Common task which should be done in loop is to find maximum and minimum of sequence of values. File Temps.java contains program which reads in sequence of hourly temperature readings over 24- hour period.

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