Back to Browse

Quick Sort Technique in Data Structure Using C

23 views
Apr 8, 2021
51:23

Quick Sort: Quick sort is very faster sorting technique and it is the most popular sorting method. Quick sort can sort a list of data elements very efficiently faster than any of the common sorting method. This method is sort two small arrays than one large one. This technique main base is to divide and conquer. The quick sort is works as first you can define Pivot element. Most of cases first left element defines as a Pivot element. After that fix the place of Pivot element using following two rules: 1. Right to left search smaller element compare to Pivot element. 2. Left to right search large element compare to Pivot element. If it is found than swap the smaller element or large element place of Pivot element. After apply these rules whole large list divided into two smaller lists. First list is smaller elements compare to Pivot element are place as left side of Pivot element and second list is large element compare to Pivot element are place as right side of Pivot element. After fix place of Pivot element, apply same rules of two sub lists. At last you can find whole list as sorting as ascending or descending order. This concept is based on recursion. The quick sort is also known as partition exchange sort. The quick sort process can be explain with the help of below figure: 0 1 2 3 4 5 6 7 6 2 7 4 9 5 8 10 Suppose 1-D Array contains 8 elements, Pivot Element 0 1 2 3 4 5 6 7 6 2 7 4 9 5 8 10 Then the process of quick sort beginning with 0th location 6 first element and Pivot element, with last element 10 to search right to left, comparing each element with 6 and stopping at the first number less than 6. From the right hand side 5 is the first smaller number than 6 and interchanged to both elements. 5 2 7 4 9 6 8 10 At this position, towards right side of 6 all elements are greater and we search next element from in the opposite direction, left to right from 1st location, comparing each element with 6, from the left side 7 element is the greater than 6, then interchange 6 and 7 as shown in above figure. 5 2 6 4 9 7 8 10 At this position, the right side of 6 one element of 4 is smaller than 6 than interchange both elements and we get new array as shown below figure : 5 2 4 6 9 7 8 10 Sub Array1 Pivot Element Sub Array2 And at this stage, there are two sub part of original array : 1. Sub Array which all elements are smaller than Pivot element 6. 2. Sub Array which all elements are greater than Pivot element 6. Apply the same process on sub Array1 and sub Array2 and at last we get than below array as ascending order sorted. 2 4 5 6 7 8 9 10 Advantages of Quick sort are as follow: 1. It is very fastest sorting technique. 2. This sorting technique hand large list. Disadvantages of Quick sort are as follow: 1. In this sorting technique required complex algorithm comparing to other sorting techniques. 2. Use the recursive function in this sorting technique. Thus, not easily understand at first time.

Download

0 formats

No download links available.

Quick Sort Technique in Data Structure Using C | NatokHD