Quick Sorting
=============================================================
The QUICKSORT algorithm, first introduced by C.A.R. Hoare, is
indeed simpler than MEDIAN SORT,
http://opensourceframework.blogspot.com/2010/09/median-sorting.html
QucikSort Complexity
Best O(n log n)
Average O(n log n)
Worst O(n^2)
=================================================================
Quick Sort Algorithm
Sort(Array)
quickSort(Array,0,n-1)
end
quickSort(Array,left,right)
if(left<right) then
pi=partition(Array,left,right)
quickSort(Array,left,pi-1)
quickSort(Array,pi+1,right)
end
partition(Array,left,right)
p=selectPivot in Array[left,right]
Swap Array[p] and Array[right]
store left
for i=left to right -1 do
if(Array[i]<=Array[rigth])
then
swap Array[i] and Array[Store]
store++
swap Array[Store] and Array[right]
return store
end
===========================================================================================
--
ANish
No comments:
Post a Comment