# Write a program on Quick Sort in Java Programming ?

##### Introduction :

Hii all, here we are going to code one of the most popular and interesting code for sorting i.e. Quick Sort.Here we are going to arrange our data in ascending order.The strategy to fix the code is, we are taking initial position as “pos” and the integer place at the 0th position of an array pass by us is known as “pivot” . we consider pivot as the minimum number of an array and then we started comparing the integers with there upcoming integer and as we find the minimum integer in the rest array we comapre it to the pivot, if the integer at a[pos] is lesser than the pivot then we interchange the position of a[pos] and pivot.

##### Description Of Program :

First of all, I would like to tell you we are constructing our product using functions, initially we will check whether the left integer is greater than the right integer if yes, then we will return from thet position only.Moving forward initially in the introduction part we have already discuss the strategies.Again we are calling two functions and that is, if the entered data is greater that the a[pos] then the left position will move to pos+1 position and if less than the right position will move pos-1.Then at the main fuction we pass an array again 0th position is consider as the 0 and last integer’s position is a.lenght-1.Hope you find it helpful.

Thank You!

##### CODE :

package arrays;

public class QuickSort {
static void quickSort(int a[],int left,int right){
if(left>=right)
return;
int pivot=a[left];
int pos=left;
int t;
for(int i=left+1;i<=right;i++)
{
if(a[i]>=pivot)
continue;
pos++;
t=a[i];
a[i]=a[pos];
a[pos]=t;
}
t=a[left];
a[left]=a[pos];
a[pos]=t;
quickSort(a, left, pos-1);
quickSort(a, pos+1, right);
System.out.printf(“left=%s, pos=%s, right=%s\n”,left,pos,right);
}
public static void main(String[] args) {
int a[]={10,15,5,66,5,44};
quickSort(a, 0, a.length-1);
for(int i=0;i<=a.length-1;i++)
System.out.print(a[i] + “,”);
System.out.println();
}
}

##### OUTPUT :
{"ft_lang_label":"__label__en","ft_lang_prob":0.7409605,"math_prob":0.9926722,"size":1948,"snap":"2020-10-2020-16","text_gpt3_token_len":496,"char_repetition_ratio":0.12911522,"word_repetition_ratio":0.0,"special_character_ratio":0.26694044,"punctuation_ratio":0.16444445,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9959463,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-02-22T03:35:30Z\",\"WARC-Record-ID\":\"<urn:uuid:e9bd82b0-2b2d-450e-8fa8-ded828d273eb>\",\"Content-Length\":\"97658\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e145e612-689f-4bea-a39e-9253be946589>\",\"WARC-Concurrent-To\":\"<urn:uuid:321b8b64-b2d1-49c0-a60d-f2e280aec40f>\",\"WARC-IP-Address\":\"148.66.136.211\",\"WARC-Target-URI\":\"http://blogs.hypatiasoftwaresolutions.in/write-a-program-on-quick-sort-in-java-programming/\",\"WARC-Payload-Digest\":\"sha1:SISRXMDX7SDUQ2DAT6KARD42FDNZY3TV\",\"WARC-Block-Digest\":\"sha1:GIRBPCJWD5ZCJ6LDV5IKFZY2D6XMEJON\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-10/CC-MAIN-2020-10_segments_1581875145648.56_warc_CC-MAIN-20200222023815-20200222053815-00192.warc.gz\"}"}