By | 10.10.2016

# Quick Sort using Arrays

Write a C program to implement Quick Sort using Arrays. Here’s simple C program to implement Quick Sort using Arrays in C Programming Language.

Quick sort is a divide and conquer algorithm. Quick sort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quick sort can then recursively sort the sub-lists.

In c quick sort we take the one element called as pivot,then we list all the smaller elements than pivot, and greater than pivot. after partitioning we have pivot in the final position. After recursively sorting the partition array, we get the sorted elements.

## C Quick Sort Algorithm :

1. If n < = 1, then return.
1. Pick any element V in a[]. This is called the pivot.
1. Rearrange elements of the array by moving all elements xi > V right of V and all elements x­i < = V left of V. If the place of the V after re-arrangement is j, all elements with value less than V, appear in a, a . . . . a[j – 1] and all those with value greater than V appear in a[j + 1] . . . . a[n – 1].
1. Apply quick sort recursively to a . . . . a[j – 1] and to a[j + 1] . . . . a[n – 1].

### Complexity : :

Best Case – O(n log n)

Worst Case – O(n^2)

Average Case – O(n log n)

It is comparison sort which works on divide and conquer technique. It is in-place partitioning algorithm and one of the fastest sorting techniques available till date.

Here is the source code of the C program to implement Quick Sort using Arrays. The C program is successfully compiled and run(Codeblocks) on a Windows system. The program output is also shown below.

### OUTPUT : :

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval. 