This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to use quick sort  algo Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to use quick sort  algo" Watch "how to use quick sort  algo" New topic
Author

how to use quick sort algo

harish goyal
Ranch Hand

Joined: Aug 28, 2005
Posts: 51
how to do quick sort in java.
suppose i have a rray of 10 element;
int a[] ={ 4,5,2,8,4,6,2,4,8,9)
i want to sort them .
in quick sort . we pivot one element and then
find all the nummber below it and about it.
than we sort it seprately.

please help me to understand this concept of quick sort
i want to use quick sort algo in java to sort these elements in java
can anyone help
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

http://www.google.com/search?q=quick+sort
http://faq.javaranch.com/view?TellTheDetails
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Writing an implementation of Quicksort is going to be a fairly significant job. Using an existing implementation to sort some stuff is very easy. Can you clarify which you have to do? For example, a school assignment might require you to write your own but a job assignment would deliver better results sooner by using what's in the Java libraries.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39577
    
  27
Quicksort is generally credited to be the fastest sorting algorithm in most cases, but merge sort isn't bad either. And it's implemented in the Collections.sort methods, so you get it for free
[ August 29, 2005: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by harish goyal:
how to do quick sort in java.
suppose i have a rray of 10 element;
int a[] ={ 4,5,2,8,4,6,2,4,8,9)
i want to sort them .
in quick sort . we pivot one element and then
find all the nummber below it and about it.
than we sort it seprately.

please help me to understand this concept of quick sort
i want to use quick sort algo in java to sort these elements in java
can anyone help

Typically, you should just do

Unless you want to implement quick sort yourself. If so, there are plenty of descriptions about the algorithm online or in any decent text about data structures. Typically, the description will include pseudocode that you can easily translate into Java. If you need help with this translation, let us know.

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use quick sort algo
 
Similar Threads
programming basics
Encryption/Description
Intuition in Java
Which would be better?
sorting