This is a created
article in which the information may have evolved or changed. "' Gopackage mainimport (" FMT ") func main () {array2: = []int{3, 2, 1}heapsort (array2) fmt. Println ("Heapmy", Array2)}func heapsort (array []int) {EP: = (len (array)-1) >> 1fmt. Println (EP) for I: = EP; I >= 0; i--{heapt (array, I, Len (array)-1)}for I: = Len (array)-1; i > 0; i--{array[0], array[i] = Array[i], array[0]heapt (array, 0, i-1)}}func heapt (array []int, start int, end int) {le: = start * * + 1re:
than base from the front - $ if(I >= J) Break;//Note that the equals sign $ - swap (Arry[i], arry[j]); - } the -Swap (Arry[lo], arry[j]);//determine the location of JWuyi the returnJ; - } Wu - voidQsort_3way (vectorint> arry,intLointhi) About { $ if(Lo >= hi)return; - - intLt=lo, i=lo+1, gt=Hi; - intPivot =Arry[lo]; A + while(I GT) the { - if(arry[i]pivot) $Swap (arry[lt++], arry[i++]);//i++, should be Lt->pivot, after Exchange lt++, pivot, i+
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.