Quick sort using recursion - Quick sort using recursion

Quick sort using recursion

Posted on

Implement Quick sort using recursion

 

In this post we will see how to implement quick sort using recursion in c/c++. Quick sort is simple and efficient algorithm for sorting items in array or elements in array. Its is very common algorithm used for sorting and asked in interviews as well.

Quick sort using recursion - Quick sort using recursion

Features of Quick sort

  • Worst-case performance‎: ‎O(n2)
  • Average performance‎: ‎O(n log n)
  • Best-case performance‎: ‎O(n log n)

Quick sort using recursion work is such as way that we need to select a pivot element. Now reorder the elements which are less than pivot should come before pivot. Similarly elements which are greater than pivot will come after selected pivot element. We need to repeat this process recursively on the element array.

Beyond this below implementation we have many different types of quick sorts available which are more efficient is specific scenarios.

Quick sort source code

if(i)>;i++)>

Quick sort using recursion Output

1)Quick Sort

2)Quit

Enter your choice : 1

Enter no of elements :6

Enter array elements :60 33 70 84 21 50

Sorted array is :21 33 50 60 70 84

1)Quick Sort

2)Quit

Enter your choice : 2

);>)>)>;i++)>

Source projectgeek.com