QUICK SORT WITH EXAMPLE
ฝัง
- เผยแพร่เมื่อ 1 ก.ค. 2019
- 1. Choose starting element as PIVOT
2. Initialize i to starting element and j to ending element.
3. Repeat the following procedure until i less than j
3.1 Keep on increment i value until element at position i less
than or equal to PIVOT
3.2 Keep on decrement j value until element at position j greater
than PIVOT
3.3 if i less than j then swap element at position i & element at
position j
4. if i greater than j then swap element at position j & PIVOT
Finally j position is the PIVOT position so that elements left to PIVOT are less than PIVOT value and elements right to PIVOT are greater than PIVOT.
Do the same process for two partitions
partition1 - low to PIVOT-1
partition2 - PIVOT+1 to high
Great explanation, best on the net, thanks alot, i checked many tutorial but i did not have any clue , but u described precisely
You always try to make things simple!
Sir can u explain the quick sort program in next video...
Thank you very much sir
Ur explanation is very easy to understand when compared to my lecturer's explanation
I will refered to my frnds also❤️🙏
Awesome lecture, Thank you sir 🙏
Sir ur veidoes are so helpful in exam time . Thanks for providing
Thanks you sir...ur explanation is very clear...but I felt that,it is very complicated and confusing with lots of calculation steps
Thanks sir, your videos help me a lot.
Superb explanation sir👍
thank you sir.ur explanation is really good . sir please upload videos on hashing and it's functions in data structures
What step should follow ,at starting if there is no element greater than pivot? Where I should keep i position?
Really nyc sir.. understood this video
Sir
I need a example of taking middle element as a pivot
Thank u for explaining in so easy language
Anna NV super explained, keep it up and do more vedios on data structures
I can understand clearly thank you so much sir 😊
sir i wached all ur videos and i like it and pls explain all code also sir
Good explanation
Hi sir ur vedios r awesome easy to understand . Data structures and algorithms in c programming I want parsing arithmetic expression Plzzz do the vedio sir
Thank you sir ☺️
Thanks for the valuable content sir. Sir your algorithm is very simpler than geeks for geeks also. Always you make things easier to understand. Once again thank you sir 🙏🙏🙏
Thanks for your support towards our channel.
It is helpful sir thank you
Tq sir good lecture
Thank you so much sir...
thank you so much sir for this valueable content.. it really helps me ..
sir make video program in quick sort...thanks for making this video...
Sir, u gave condition for swapping, i>j and i
@random_queen same doubt 🥴
Sir is there any +infinity at the high side
thank u very much sir..can u write a programme for quick sort
Thank u sir 👍👍
Pls teach minimum spinning tree
Make vedios on c++ programming language
In second partition how taking the 50 as pivot....
nice explanation sir
Meru super sir
Thank you sir ❤️❤️❤️❤️❤️
Thanks....sir
Thank you so much sir
Sir I understand clearly ,but sir is there any chances to give the repeated elements in the question like 2,5,4,7,6,2 like this
sir when i=j , what should we do?
Sir here last step we have to swap j and pivot element sir. Will u please explain it??
Sir can u please make the Redblock tree insertion and deletion tutorial
Sir please make a video for program of quick sort....
Can you make a tally learning vedios
Give quick sort explanation for this example
15,5,100,28,13,6 from first partition
22:41 isn't it 10 > 10 instead of 10 > 20 as the pivot is 10? also did not swap 10 and 20 when i is not less than j. little messed up.
Thanks annaya
Sir I have a doubt. I have problem with my function to find pivot position.And my input={60,50,40,30,20,10} output comes like {0,20,30,40,50,60}. And the code is
int findpivot(int arr[],int low,int high)//FINDING PIVOT POSITION
{
int pivot=low;
int i=low+1,j=high,temp;
if(i
thanks sir.
nice sir
Tq sir 😍
Thank you sir
Sir, can i ask an example of real life scenario using quicksort
Please code it for c++
supper sir thank you so much
Sir at 22:43 (a[j]>pivot, this condition is going on), pivot is initially 10 but you took 20 as pivot and and did10>20 which is wrong.cause after decrementing j is at 0th index which is 10 and pivot is also 10 so it should be 10>10
Yeah exactly i am also stuck at this point... And in next recursion why should we take 'i' as 10 and pivot whereas 'j' as 20 why so?
Now 11 months have been passed away., Did you guys get your answers from anywhere?
You have an eagles eye, He made a mistake but the outcome is 'false' just as he stated, invariably, he's correct ... (10>10 ,10 is not greater than 10 so it is 'false'). Therefore, 10 is j and also the pivot, it can't be swapped. Recall, when i > j, j =0 and i = 1. swap( a[j],pivot) .
Sir in second step our j value is 40 sir but why u take pivot value at every step in j
Program? Sir
Sir kindly upload greedy algorithm as soon as possible
sir pivot means
sir at 28:30 how i value becomes 2 sir?is i=1 there
Bcoz a[i] =40 and pivot value is 50
Now, condition a[i]
Nice Sir Thanks..Also make videos on C++
Can u make complier design notes rply me
Can u upload complir design sub video
Upload complie deisgn sub
Sir please explain quick sort program
Like your vedios sir, but we want in less than 10 min
Didnt understand j> piviot in ie 10>10 j but u ae mention 10>20
Explanation sir.............................Explanation Anthe .........................!!!!!
22:42 in [j>pivot] j-- then here pivot is 10 so how [10>20], I have confused
Trace the quick sort algorithm to sort the list C, O, L, L, E, G, E in alphabetical order idi ans pettara sir please try chesanu nenu kani ravatledu
Sir in right side of pivot case
Around 20-21min
We have to take i=pivot+1=3
J=5
But u took I=0and j=2??????????
Simple program for quick sory and bubble sort please sir
Did you write algorithm
Bro pls I need tis in java code format ...
public class QuickSort {
public static void main(String[] args) {
int ary[] = { 1, 30, 20, 10, 50, 60, 40 };
System.out.println(" Length Is ; " + ary.length);
print(ary);
sort(ary, 0, ary.length - 1);
print(ary);
}
private static void sort(int[] ary, int lowerBound, int upperBound) {
int position = partation(ary, lowerBound, upperBound);
partation(ary, lowerBound, position - 1);
partation(ary, position + 1, upperBound);
}
private static int partation(int[] ary, int lowerBound, int upperBound) {
int pivot = lowerBound;
int start = lowerBound;
int end = upperBound;
while (start < end) {
while (ary[start] ary[pivot]) {
end--;
}
if (start < end)
swap(ary, start, end);
else {
swap(ary, end, pivot);
}
}
return end;
}
private static void swap(int[] ary, int start, int end) {
int temp = ary[start];
ary[start] = ary[end];
ary[end] = temp;
}
private static void print(int[] ary) {
for (int i : ary) {
System.out.print(i+" ");
}
System.out.println("");
}
}
By hearing background voice I can say that you are TELUGU PERSON
Sir we want the program on quick sort
Sir u r making us confuse with pivot values...u r saying that..30 is pivot value . At the same time u r saying that.. starting value is pivot .. make it clear
little bit confusion
Sir please write code also
Some confusion
Explain in clear
Sir mari two elements same ayite
Sir explain with program
54 26 93 17 77 31 44 55 20 please solve the problem sir i am confused on quick sort
Sir I have a doubt I think at 22:50, there should be 10 greater than 10 .
10 is less than equal to 10 so condition pass n proceed for further increment of i
You are correct. it should not be 10>20, although he said it's false which is right, 10>10 will also be 'false' because 10 is not greater than 10. So it's also false.
@@sharwanajith6835 The condition requires only (> greater than), if not, then it's 'false'. 10 means 10 is not greater than 10 so it's false
The condition requires only (> greater than), if not, then it's 'false'. 10 is not greater than 10, it's false. no increment
Why you don't make video in hindi to better explanation your English such a confusing more than question 🙋
Your English are perfect
😂😂😂first u correct ur english
void quicksort(int low_index, int high_index)
{
int *p;
p = &a[low_index];
for(k=0;k
hi
i think you have missed the declaration part for function quicksort() so declare the function and your problem will be solved.
Thanks for your interest and support towards our channel.
@@sundeepsaradhi you mean I should declare the function globally?
Sir Telugu lo cheppandi sir
Im nt understanding complier dedign sub up load diz sub
not understant