quick sort

Ads

 
 
 

Share on Google+Share on Google+

moni sharma
quick sort
1 Answer(s)      6 years and 4 months ago
Posted in : Java Beginners

sir, i try to modify this one as u sugess me in previous answer "array based problem" for run time input.but i am facing some problem.plz solve this one also.

import java.util.*; public class QuickSort1 { public static void quick_srt(int array[],int low, int n){ int lo = low; int hi = n; if (lo >= n) { return; } int mid = array[(lo + hi) / 2]; while (lo < hi) { while (lo mid) { hi--; } if (lo < hi) { int T = array[lo]; array[lo] = array[hi]; array[hi] = T; } } if (hi < lo) { int T = hi; hi = lo; lo = T; } quick_srt(array, low, lo); quick_srt(array, lo == low ? lo+1 : lo, n); }

public static void main(String a[]){ Scanner input=new Scanner(System.in); int array[]=new int[10]; int i;

    System.out.println("       Quick Sort\n\n");   
    System.out.println("Values Before the sort:\n");    
    for(i = 0; i < array.length; i++){
    array[i]=input.nextInt();
     }
    for(i = 0; i < array.length; i++){
    System.out.println(array[i]);
        }



  quick_srt(array,0,array.length-1);
  System.out.print("Values after the sort:\n");    
  for(i = 0; i <array.length; i++)
  System.out.print(array[i]+"  ");
   System.out.println();  

  System.out.println("PAUSE");

}

}

Ads
View Answers

January 5, 2011 at 10:14 AM


Hi Friend,

Visit Here

Thanks


Ads









Related Tutorials/Questions & Answers:
quick sort
; System.out.println(" Quick Sort\n\n"); System.out.println("Values Before...quick sort  sir, i try to modify this one as u sugess me in previous... static void quick_srt(int array[],int low, int n){ int lo = low; int hi
quick sort
; System.out.println(" Quick Sort\n\n"); System.out.println("Values Before...quick sort  sir, i try to modify this one as u sugess me in previous... static void quick_srt(int array[],int low, int n){ int lo = low; int hi
Advertisements
quick sort
; System.out.println(" Quick Sort\n\n"); System.out.println("Values Before...quick sort  sir, i try to modify this one as u sugess me in previous... static void quick_srt(int array[],int low, int n){ int lo = low; int hi
Quick Sort In Java
Quick Sort in Java      ... to sort integer values of an array using quick sort. Quick sort algorithm is developed by C. A. R. Hoare. Quick sort is a comparison sort. The working
Quick Sort in Java
Quick sort in Java is used to sort integer values of an array. It is a comparison sort. Quick sort is one of the fastest and simplest sorting algorithm... sort, etc. The complexity of quick sort in the average case is Θ(n log n
Quick Sort in Java
Quick Sort in Java Quick Sort in Java is used to sort elements of an array. Quick sort works on divide and conquer strategy and comparison sort... into two sub-arrays. The complexity of quick sort in the average case is &Theta
Sort
Sort  program to sort a list of numbers in decendimg order   Hi Friend, Try the following code: import java.util.*; class SortListInDescendingOrder{ public static void main(String[] args
Waiting for ur quick response
Waiting for ur quick response  Hi, I have two different java programs like sun and moon. In both of these two programs i have used same class name like A. For example, File name:sun.java Then the code is here: Class
bubble sort
bubble sort  how to calculate the number of passes in bubble sort
insertion sort
insertion sort  how many arrays needed for insertion sort and why
insertion sort
insertion sort  write a program in java using insertion sort
insertion sort
insertion sort  write a program in java using insertion sort
insertion sort
insertion sort  write a program in java using insertion sort
Array sort
Array sort  Program that uses a function to sort an array of integers
bubble sort
bubble sort  write a program in java using bubble sort
insertion sort
insertion sort  write a program in java using insertion sort
buble sort
buble sort  ascending order by using Bubble sort programm   Java BubbleSort Example
SEARCH AND SORT
SEARCH AND SORT  Cam any one provide me the code in java that : Program to search for MAX,MIN and then SORT the set using any of the Divide and conquer method
Struts Quick Start
Struts Quick Start Struts Quick Start to Struts technology In this post I will show you how you can quick start the development of you struts based project... of the application fast. Read more: Struts Quick Start
Please help need quick!!! Thanks
Please help need quick!!! Thanks  hey i keep getting stupid compile errors and don't understand why. i'm supposed to use abstract to test a boat race simulation program of sorts here is my code: RentforthBoatRace.java public
php array sort by value
php array sort by value  an example to sort the array by value
php array sort by field
php array sort by field  Array sort by field in PHP
php array sort by key
php array sort by key  php script to sort array by key
php array sort functions
php array sort functions  Sort function in php
Insertion Sort In Java
. There are more efficient algorithms such as quick sort, heap sort, or merge sort... Insertion Sort In Java     ... In this example we are going to sort integer values of an array using insertion sort
i need a quick response about array and string...
i need a quick response about array and string...  how can i make a dictionary type using array code in java where i will type the word then the meaning will appear..please help me..urgent
Tomcat Quick Start Guide
Tomcat Quick Start Guide       This tutorial is a quick reference of starting development application using JSP, Servlets and JDBC technologies. In this quick and very
Insertion Sort Applet
Insertion Sort Applet  I need Insertion Sort Applet code was design by Dr. Daniel Liang Please
Insertion Sort Applet
Insertion Sort Applet  Please All , I need Insertion sort applet program
insertion sort applet code
insertion sort applet code  i need Insertion Sort Applet Program
Tutorials   
Java Spring Hibernate Struts Training java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile?

Ads

 
Advertisement null

Ads