Java Tutorial

 
 
 
 
import java.io.*;

class sort
{
      String str;
      int size,sortArr[];

      public void getdata()
      {
             System.out.print(\"Enter how many data you want to enter : \");
             System.out.flush();
             try{
                 BufferedReader obj=new BufferedReader(new 

InputStreamReader(System.in));
                 str=obj.readLine();
                 size=Integer.parseInt(str);
                 sortArr=new int[size];
                 for(int i=0;i<size;i++)
                   {
                       System.out.print(\"Enter element at \"+(i+1)+\"th 

position  :  \");
                       System.out.flush();
                       str=obj.readLine();
                       sortArr[i]=Integer.parseInt(str);
                   }
                }
            catch(Exception e)  {}
            QuickSort(sortArr,0,size-1);
      }

      public void  QuickSort(int sortArr[],int lb,int ub)
      {       
                int i,j,key,flag=0,temp;
                if(lb<ub)
                {
                   i=lb;
                   j=ub+1;
                   key=k[i];
                   while(flag!=1)
                     {
                         i++;
                         while(k[i]<key)
                              i++;
                        j--;
                        while(k[j]>key)
                              j--;
                        if(i<j)
                          {
                              temp=k[i];
                              k[i]=k[j];
                              k[j]=temp;
                           }
                        else
                          {
                             flag=1;
                             temp=k[lb];
                             k[lb]=k[j];
                             k[j]=temp;
                          }
                    }
                QuickSort(sortArr,lb,j-1)
                QuickSort(sortArr,j+1,ub);
            }
        }

    public void display()
    {
         System.out.println(\"\\nAfter Sorting\");
         for(int i=0;i<size;i++)
              System.out.println(sortArr[i]);
    }
}


class QuickSort 
{
    public static void main(String args[]) 
    {
          sort ob1=new sort();
           System.out.println(\"=====QUICK SORT=====\\n\");
            ob1.getdata();
            ob1.display();
    }
}

    Related Post:
  1. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  2. An applet program showing Clicked Event on canvas

  3. An applet program to take user input and display

  4. An applet program to display barchart of given data

  5. Program to show an example of Calling a Base Class Method from a Derived Class

  6. Program to show the use of operator (&lt;&lt;) Shift Left filling with zero from the right

  7. Program of bubble sort

  8. Program to show an example of using user-defined package in a program

  9. Program to show the use of operator (&gt;&gt;&gt;) Shift Right, filling with zeros from the left

  10. Program to show an example of extraction of characters from a StringBuffer objects

  11. Program of an applet to illustrate BarChart

  12. Program that accepts a shopping list of items from the command line and stores them in a vector. Also provide facility to perform operation

  13. Program of storing and retrieving integers using data streams on a single file

  14. CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL

  15. Program to Display Output in triangular shape

  16. RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct

  17. An applet program that creates string dynamically and displays it

  18. Program of inventory management and demonstrating interactive input and output

  19. Program to copy the elements of an array into another array in reverse order and print them

  20. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

 
 
Didn't find what you were looking for? Find more on An applet program to perform quick sort