WHAT IS QUICKSORT

E19cse226
2 min readMar 24, 2021

--

Quick Sort is a widely used sorting algorithm in computer science.

Quick Sort employs a divide-and-conquer strategy. It makes two empty arrays to hold elements less than the pivot value and elements greater than the pivot value, then sorts the sub arrays recursively. The algorithm consists of two simple operations: swapping objects in place and partitioning a portion of the array.

Quick Sort Algorithm:

1-In the array, look for a “pivot” item. For a single round, this item serves as the comparison point.

2-Begin with the first item in the array (the left pointer).

3-Begin a pointer (the right pointer) at the array’s last item.

4-Move the left pointer to the right if the value at the left pointer in the array is less than the pivot value (add 1). Continue until the pivot value is greater than or equal to the value at the left pointer

5- Move the right pointer to the left if the value at the right pointer in the array is higher than the pivot value (subtract 1). Continue until the pivot value is less than or equal to the value at the right pointer.

6-Swap the values at these points in the array if the left pointer is less than or equal to the right pointer.

7-Move the left pointer one space to the right and the right pointer one space to the left.

Return to step 1 if the left and right pointers do not meet.

QUICK SORT ANALYSIS —

And Here’s My YouTube Video For More Explanation -

Blog by Abhiyankar Sindhu

--

--

E19cse226
E19cse226

No responses yet