# Quicksort algorithm in the data structure for example?

Hello Friends, In this blog(Quicksort algorithm in data structure with example), I am going to let you know about a very interesting sorting technique or algorithm which is known as Quick Sort.

In this blog post(Quicksort algorithm in the data structure for example), we are going to let you know about What is a quick sort in data structure? What is a quick sort in data structure with an example? What is meant by quick sort? How do you write a quick sort?….

… What is a quick sort of data structure? How do you sort a structure? What do you mean by sorting in the data structure? What is searching and sorting in the data structure?|Quicksort algorithm in data structure with example|

When you will read or go through this quick sort then you will find it a bit tricky sorting technique where you need to remember a few rules to complete all the procedures during this quick sort|Quicksort algorithm in data structure with example|

This quick sort is based on the divide and conquers technique, where we divide a given list into sublists by following a procedure.

And by dividing the list into sublists we sort out the whole list and finally, we get a sorted list using the quicksort|Quicksort algorithm in data structure with example|

When you or especially students will read this quick sort for the very first time then they might get it difficult to understand better as this quick sort has some tricky approaches to sorting the list.

But here we will explain to you in a very simple way how to sort a list using Quicksort.

### What is a quick sort in the data structure for example?

For understanding the quick sort, you just need to follow the below-given procedure step by step.

suppose you have given a list to sort out using the quick sort technique:

44 23 76 84 87 72 36

Then the very first thing you need to do is just do the naming for a few specific elements of the list as given below.

Here the first element is marked as low and this is also our pivot element which will be the center of the list partition.

The last element is marked as high and that will also be known as the left element.

## Now see a few simple rules to sort out the list below.

if right < low then move the right handle one position forward towards high.
if left > low then you need to move the left handle one position forward toward low.

So the basis of the above condition we need to move our right and left handles across the list. Now see below more conditions for swapping the elements of the list.

When there is no movement in the right and left handle or both the above-given conditions are false then we need to swap the right and left elements. and we also move the right and left handles toward their moving direction.

We repeat this process until the right and left handles cross each other. And once they cross each other or we also denote this as right > left (here we do not compare the value it is just crossing the left and right handle) then we swap left and low elements.

Now we see the position of our pivot element, in this case, we have 44 as our pivot element. and we divide the list into sublists by assuming our pivot as our divide point,…

… as you will always find that the left side elements of the pivot will be less than the pivot and the right side elements will be greater than a pivot.

So we get two sublists again and with the same procedure, we again start sorting out the list.

See an example given below with the same list of elements given above.

swap a[right] and a[left] and move right and left

Since right > left, so swap a[left] and a[low]

36 23 44 84 87 72 76

low
36 23 44 84 87 72 76

At this point 44 is at its proper place, and the list is divided into two parts,
which will also be sorted using the same procedure

Since right = left, so swap a[left] and a[low].

{23 36}

At this point 36 is in the proper place and the list contains only a single element,
so further sorting is not required in this part.

swap a[right] and a[left] and move right and left further.

Since right > left, so swap a[left] and a[low]

72 76 84 87

At this point 84 is at its proper place. And the list is divided into two parts {72 76} and {87}.
The second list contains only a single element, its sorting is not required, First part is now to be sorted below using Quick Sort.

Since, right = left, we need to swap a[low] and a [left], but here 72 is at its proper place, so we will not swap here. And here we get only one list that contains only one single element {76}, so no further sorting is required here.

{72 76}

Hence the result in the sorted list is as follows using Quick Sort

23 36 44 72 76 84 87

#### Please go through the below extensive blog link related to the sorting techniques:

Sorting Algorithm And Their Time Complexity In Data Structure.

What is meant by the Shell sort in data structure?

Radix Sort In Data Structure / What is the radix sort used for?

Merge Sort In Data Structure/ What is merge sorting in data structure?

Selection Sort In Hindi In Data Structure/ How do you perform a selection sort? / Selection sort kya hai?

Bubble Sort In Hindi In Data Structure/ What is bubble sort for example?/ Bubble Sort Kya Hai?

Insertion Sort In Hindi/ insertion sort step by step/ Insertion sort kya hai?

Searching In Data Structure/ What is the searching in data structure?

## Conclusion:

Within this blog post(Quicksort algorithm in data structure with example), we have gone through What is quicksort in the data structure, What is quick sort in data structure with an example, What is meant by quick sort, How do you write a quick sort, What is quicksort in the data structure, How do you sort a structure, What do you mean by sorting in the data structure, What is searching and sorting in the data structure.

In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.

Hope! you would have enjoyed this post about the Quicksort algorithm in a data structure for example.

Please feel free to give your important feedback in the comment section below|Quicksort algorithm in data structure with example|

Have a great time! Sayonara!

#### Anurag

I am a blogger by passion, a software engineer by profession, a singer by consideration and rest of things that I do is for my destination.