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. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  2. Program of telnet server - client

  3. Write a program for restaurant

  4. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  5. Program to show some properties of StringBuffer object

  6. An applet program that displays Text at the center of the string which is passed as parameter

  7. An applet program showing Clicked Event on canvas

  8. Program to Display Output in triangular shape

  9. Program of writing Bytes to a File

  10. Program that reads and writes random access file

  11. Program in CORBA which takes a long sentence from the client (at least 7 words), passes to the server, server separates out each word

  12. Develop a CORBA application that takes a string from client and returns whether it is palindrome

  13. Corba program of date operations

  14. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

  15. Program to sort the contents of an array using Bubble Sort

  16. Program to show the use of Switch Statement for the same statement for several different case labels

  17. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object

  18. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

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

  20. Socket program of HTTP Server

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