# Help Me/QuestionQuick Sort Algorithm.

#### steve taylor

White Belt
As we know quick sort is the practical sorting algorithm, It is in-palace sorting algorithm (i.e. It does not require external memory for the sorting operation). Minimum time taken by the quick sort algorithm is N( log N ) which also known as best case time complexity. Its performance is worst when the array contain sorted element in this case it take N square time . Now my question is what is the algorithm for quick sort?

#### krishatg

##### Content Writer
For the algorithm of any type of sort you can refer to data structure book of schaum series . Its PDF are also available online you can also download them. It is written in a very understandable form in this book and it is most referred book.

#### steve taylor

White Belt
For the algorithm of any type of sort you can refer to data structure book of schaum series . Its PDF are also available online you can also download them. It is written in a very understandable form in this book and it is most referred book.
I prefer some books but I found some difficulty to calculate best case , average case and worst case time and space complexity. Hence I write the thread for more help. Some questions related to time analysis are very difficult to answer with the help of schaum series concepts.

#### VIVEK KUMAR

White Belt
Quick sort algorithm with recursive function call , its work with partition algorithm -
Code:
``````Quicksort(a,p,q)
{
if(p==q)
return(a[p])

else
{
m=partition(a,p,q)
quicksort(a,p,m-1)
quicksort(a,m+1,q)
returen (a)
}
}``````

Partition algorithm :-

Code:
``````partition (a,p,q)
{
x=a[p]
i=p ;
for (j= p+ 1; j<= q; j++)
{
if (a[j] <= x)
{
i=i+1;
swap (a[i] , a[j])
}
}
swap(a[i] ,a[p])
return (i)

}``````