Quicksort is a sorting algorithm based on the divide and conquer approach where
- An array is divided into subarrays by selecting a pivot element (element selected from the array).
While dividing the array, the pivot element should be positioned in such a way that elements less than pivot are kept on the left side and elements greater than pivot are on the right side of the pivot.
- The left and right subarrays are also divided using the same approach. This process continues until each subarray contains a single element.
- At this point, elements are already sorted. Finally, elements are combined to form a sorted array.
Output:
Enter size of array :6
Enter 6 elements: 123
36925
-56
0
45
456
Sorted elements : -56 0 45 123 456 36925
need an explanation for this answer? contact us directly to get an explanation for this answer