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. An applet program to display moving banner

  2. Program to show the use of some Math Methods

  3. Program of creating a file using text fields in windows

  4. Program to show an example of using constructors in a class to initialize its data members

  5. RMI based application for login validation based on data saved in text file stored on the server and will display appropriate message to the client..

  6. An applet program to display sum of two number of textField

  7. An application that combines several classes and interface

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

  9. Program to show an example of Driving and using a Class

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

  11. Corba program of Count Client Applet, IDL,Server, Client

  12. Corba program to encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time.

  13. Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong

  14. Corba program of game

  15. Program that will count the number of lines in each file that is specified on the command line

  16. Program of an applet to display alternate filled and empty circle

  17. An applet program to perform quick sort

  18. Program to show an example of creating String objects from Character Arrays

  19. Program to show an example of using a Non-Static Nested Class

  20. Program to declare and initialize Integer variables and print them on the Standard Output Device

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