[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Quick Sort problem

Posted on 2004-11-23
2
Medium Priority
?
261 Views
Last Modified: 2010-03-31
i have a quick sort program which outputs the numbers in a correct sequence, but the problem is that any value that is used as a pivot during the working out process is omitted from the output.
I am unsure how to get this into the correct order

SOURCE CODE @----> http://www.newwavesound.co.uk/java

thanks

pete

0
Comment
Question by:pete420
  • 2
2 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12658488
try to replace the line:

>>                if (currentValue.compareTo(pivot) > 0)
with
                if (currentValue.compareTo(pivot) >= 0)
0
 
LVL 13

Accepted Solution

by:
petmagdy earned 400 total points
ID: 12658525
maybe better just add below:
>>            pivot = (Comparable)L.removeFirst();

add this line:

                    greaterThan.addToFront(pivot);

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question