PackageCom.swift;Importjava.util.ArrayList;Importjava.util.Collections;ImportJava.util.Comparator;Importjava.util.List; Public classQuickSort {/** Quick Sort*/ Public Static voidMain (string[] args) {string[] strvoid=NewString[] {"11", "66", "22", "0", "55", "22", "0", "32"}; QuickSort Sort=NewQuickSort (); Sort.quicksort (Strvoid,0, Strvoid.length-1); for(inti = 0; i < strvoid.length; i++) {System.out.println (Strvoid[i]+ " "); } //Sort by ComparatorList<string> list=NewArraylist<string>(); for(String str:strvoid) {list.add (str); } collections.sort (List,NewComparator<string>() {@Override Public intCompare (String arg0, String arg1) {intnum=Arg1.compareto (arg0); returnnum; } }); for(String str:list) {System.out.print (str+" | "); } } Public voidQuickSort (string[] strdate,intLeftintRight ) {String middle, tempdate; intI, J; I=Left ; J=Right ; Middle= strdate[(i + j)/2]; Do { while(Strdate[i].compareto (middle) < 0 && I <Right ) I++;//find the number that is larger than the middle value on the left while(Strdate[j].compareto (middle) > 0 && J >Left ) J--;//find the number that is lower on the right than the middle value if(I <= J) {//Replace the large number on the left and the small number on the rightTempdate =Strdate[i]; Strdate[i]=Strdate[j]; STRDATE[J]=tempdate; I++; J--; } } while(i <= J);//stop when the two are staggered if(I <Right ) {QuickSort (strdate, I, right);//from } if(J >Left ) {QuickSort (Strdate, left, J); } }}
Java algorithm interview question: What are the various methods of sorting? Please list. Implement a quick sort with java. Select at least 4 ways to sort the bubbling quick set