Quick Sort Algorithm in PHP

Quick sort algorithm was developed using the divide and conquer approach and it comes under comparison algorithm category. This is also known as partition-exchange sort. This algorithm splits the array into two sub-arrays based on the pivot position and performs the sort operation recursively till there is no more sub arrays exist. Quick sort is an easiest way of sorting technique, but it's not an efficient on large data sets.

Time Complexity

  • Best complexity: n*log(n)
  • Average complexity: n*log(n)
  • Worst complexity: n^2