2 Replies - 2465 Views - Last Post: 14 August 2012 - 01:27 PM Rate Topic: -----

#1 RCharles  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 27
  • Joined: 12-August 12

Help with QuickSort Java Netbeans(im stuck)

Posted 13 August 2012 - 07:14 PM

    private void doQuickSort() {
        JOptionPane.showMessageDialog (null, "doing quicksort" );
        if(arraydata.getText().equals("")){
            JOptionPane.showMessageDialog (null, "Please insert values to be sorted!" );
        }else
        {
           //Use split method to put the String into String array separated with " " delimeter
           String inputString = arraydata.getText();
           String[] stringParts = inputString.split(" ");
           
           //Convert String array to int array
           int[] ints = new int[stringParts.length];
           for (int i=0; i < stringParts.length; i++) {
               ints[i] = Integer.parseInt(stringParts[i]);
           }
           //System.out.println(ints[2]);
           //Pick a pivot (middle)
           int temp = ints.length/2;
           int pivot = ints[temp];
           //System.out.println("pivot is: "+pivot);
           
           //declaring the low and hi
           int templow = ints[0]; //low
           int temphi = ints[ints.length -1]; //high
           
           while(templow <= temphi){
               while(templow < pivot)
                   templow++;
               while(temphi > pivot)
                   temphi--;
               if(templow <= temphi){
             
               }
           }
        }
        
    }



Can someone help me in swapping for quicksort.
im really having difficulty.

This post has been edited by blackcompe: 13 August 2012 - 07:27 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Help with QuickSort Java Netbeans(im stuck)

#2 Moosey  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 18
  • Joined: 12-August 12

Re: Help with QuickSort Java Netbeans(im stuck)

Posted 13 August 2012 - 10:02 PM

I actually don't know many algorithms(wish I did) but while searching trying to find an answer I found this guide that goes over the QuickSort in java not sure how to put it into my own words but I hope you can get something from it.

http://www.algolist....rting/Quicksort
Was This Post Helpful? 0
  • +
  • -

#3 SPorter  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 31
  • Joined: 29-June 12

Re: Help with QuickSort Java Netbeans(im stuck)

Posted 14 August 2012 - 01:27 PM

http://www.cosc.cant...dsal/QSort.html

This is a great site to use for studying, especially when it comes to sorts and data structures. The link I gave you will help you with quicksort. It's a lot easier than you think.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1