Analysis of quicksort

  Рет қаралды 312,757

mycodeschool

mycodeschool

Күн бұрын

Пікірлер: 162
@cheems08213
@cheems08213 Жыл бұрын
Time to time i find myself coming back to your videos, sometimes for revision, sometimes for just interest and I never leave unsatisfied. These videos although are free, but are of premium quality. Better than paid courses
@tamara-kurosimonalale5238
@tamara-kurosimonalale5238 2 жыл бұрын
Incredible how your explanation made quicksort algorithm and its analysis so easy
@rafaelfonseca7942
@rafaelfonseca7942 3 жыл бұрын
14:30 As *n - k = 1*, then *k = n - 1*. Thereby, we will have a slightly different final result for this calculation: (n ^ 2 * c + n * c - 2 * c) / 2 + c1 Anyway, we conserve the fact that this algorithm takes n ^ 2 of cost in the worst case. Awesome video teacher! Super enjoyed!
@adamtki
@adamtki Жыл бұрын
I noticed that too and your comment confirmed I'm not missing something. Thanks!
@tejasjoshi1907
@tejasjoshi1907 3 жыл бұрын
2 days ago j learned about merge sort and quick sort , but at today morning I thought that I hadn't got the exact logic or idea to solve them , so I decided to learn from your channel and just completed and boom💥,I am satisfied with the explanation (deep explanation) tha k u for making such brilliant videos🔥❤️
@praveenreddykatta
@praveenreddykatta 10 жыл бұрын
I should say your videos are the best in making the things simple and understandable. Please upload more videos
@gozi323
@gozi323 7 жыл бұрын
Thank you so much for this video!!! This has to be by far the most helpful CS programming learning video, that I have ever watched.
@romxstar
@romxstar 11 жыл бұрын
thank u sooo much we just did it in school .. and i wanted to revise it and here u are uploading the video of it
@mycodeschool
@mycodeschool 11 жыл бұрын
You're most welcome Mouad Izegnane :)
@yiningli3160
@yiningli3160 5 жыл бұрын
built more confidence in challenging google from your lectures, thx !
@harshalisatwani
@harshalisatwani 7 жыл бұрын
Please upload video lectures on hashing, heap sort, bucket sort and shell sort as well.. These videos have really proved very helpful in understanding sorting algos in a better way..
@bahdjibrildjibril
@bahdjibrildjibril 9 жыл бұрын
Amazing series. It took me less that 2 hours to revise what used to take days for me.. .Best Way of teaching.
@SadiqKhan876
@SadiqKhan876 9 жыл бұрын
Amazing lectures and best way of describing things with programs and complexity analysis for every one. I am waiting for next sorting like heap,redix etc. Please please upload those too.
@BhagwanJoshi-technocrat
@BhagwanJoshi-technocrat 9 жыл бұрын
I loved the way you explained all sorting algorithms and its analysis. If you can add heap sort and radix sort in this list, that would be very helpful. Thanks :)
@londonandres856
@londonandres856 3 жыл бұрын
I dont mean to be so off topic but does someone know a way to log back into an instagram account?? I somehow lost my login password. I would love any tricks you can give me.
@joellarry71
@joellarry71 3 жыл бұрын
@London Andres instablaster =)
@londonandres856
@londonandres856 3 жыл бұрын
@Joel Larry thanks so much for your reply. I found the site on google and Im in the hacking process now. I see it takes quite some time so I will get back to you later when my account password hopefully is recovered.
@londonandres856
@londonandres856 3 жыл бұрын
@Joel Larry it did the trick and I finally got access to my account again. I'm so happy:D Thanks so much you saved my account !
@joellarry71
@joellarry71 3 жыл бұрын
@London Andres No problem =)
@amrousimen7170
@amrousimen7170 3 жыл бұрын
very thanks, you are the best teacher for algorithmic on youtube
@Utkarshkharb
@Utkarshkharb 3 жыл бұрын
17:53 if the pivot lies at index i, then there are i elements in the left partition and n-1-i elements in the right partition(In a 0-based indexing)
@hangchen6131
@hangchen6131 7 жыл бұрын
I'm addicted to your lessons... so after 4 years, are there still more?? :)
@aditya234567
@aditya234567 4 жыл бұрын
Im sorry but he passed away 6 years ago :( You can find about him here www.quora.com/Who-was-humblefool
@punamroy3965
@punamroy3965 4 жыл бұрын
@@aditya234567 the one who passed away is Harasha Suryanarayana(co-founder) and the voice youre listening on here is of Animesh Nayan
@rafaelfonseca7942
@rafaelfonseca7942 3 жыл бұрын
Teacher, at minute 17:06 we cannot forget of adding a return statement into RandomizedPartition as follows: RandomizedPartition(A, start, end) { pivotIndex
@DahliaRich
@DahliaRich 6 жыл бұрын
this is great. thanks so much. couldn't understand a word of what the instructor at school said. you explained perfectly.
@AvidLearner11
@AvidLearner11 3 жыл бұрын
Thanks so much! Your videos are so great! I now look at your channel first if I need to review something. Just about broke my heart not to be able to find heap sort amongst the videos. Something to consider!
@camuflagehugo5137
@camuflagehugo5137 2 жыл бұрын
your videos are much better than those on coursera!
@theOceanMoon
@theOceanMoon 9 жыл бұрын
where is link to description of all the maths mentioned at time 18:39
@asfandalikhan6269
@asfandalikhan6269 7 жыл бұрын
dat was bluff xD
@NiazMohammad
@NiazMohammad 7 жыл бұрын
It's not that hard to google with the term "randomized quick sort time complexity analysis"
@SAINIVEDH
@SAINIVEDH 6 жыл бұрын
look it up in cormen's book
@udaykadam5455
@udaykadam5455 5 жыл бұрын
It's forward recurrence(extremely easy stuff), computes the running time complexity. Just search it.
@AmiParikh9
@AmiParikh9 4 жыл бұрын
Superbly explained! Thank you for these videos. I have an algorithm interview, hope this helps.
@PK-en1bm
@PK-en1bm 10 жыл бұрын
Nice video :) Really helped me... Just one thing though: RandomizedPartition() should return pIndex to QuickSort() call, so I think Partition() inside RandomizedPartition() should be called as "return Partition()" Thank s for making such hugely helpful videos, keep up the good work...
@amanrohilla5956
@amanrohilla5956 5 жыл бұрын
Please add further videos of all the playlists and thank you very much for the amazing, animation explanation. Love a.
@uzairbintabish9234
@uzairbintabish9234 7 жыл бұрын
Please make an addition of Binary Search Algorithm and its analysis as it is also an important tutorial which follow Divide and Conquer Rule. Other than this you have every tutorial regarding Design and Analysis of Algorithm. P.S. YOU ARE AMAZING.
@apuravsharma7034
@apuravsharma7034 3 жыл бұрын
this channel is gold
@abdallahrazak8457
@abdallahrazak8457 7 жыл бұрын
Please in future lessons i hope you will make videos on radix sort and shell sort and thank you for these nuggets of programming lectures
@cyberpunk7702
@cyberpunk7702 11 жыл бұрын
amazing lecture !! I feel much more clear about quicksort now.
@niharikakumari6506
@niharikakumari6506 6 жыл бұрын
you are really very very good at explaining!
@sawyermcbride1522
@sawyermcbride1522 8 жыл бұрын
you should do heap and radix sort
@loveanimals-0197
@loveanimals-0197 4 жыл бұрын
Those were not in the book he copied from.
@abdoemr3436
@abdoemr3436 4 жыл бұрын
@@loveanimals-0197 what book ? i think he use algorithm in c by sedgwick
@abhi1110
@abhi1110 3 жыл бұрын
@@loveanimals-0197 he is not alive. He expired in some accident 4 years ago
@rajg7592
@rajg7592 3 жыл бұрын
@@loveanimals-0197 then go on Karen read books instead
@tek1645
@tek1645 2 жыл бұрын
@@loveanimals-0197 KZbin creators explaining topics not just in computer science but math and science are superior to outdated teaching methods of textbooks and many "professors"
@UmeshKumar-mf5bl
@UmeshKumar-mf5bl 8 жыл бұрын
THANKYOU FOR DOING SORTING ALGORITHM VIDEOS...this helped me a lot but sir please make video on heap and radix sort also
@iqbalahmad3754
@iqbalahmad3754 6 жыл бұрын
You are purely gifted sir, love your lessons
@saurabhtiwaririshi
@saurabhtiwaririshi 8 жыл бұрын
k will be equal to n or n-1?
@PriyanshuRaj-oc4tk
@PriyanshuRaj-oc4tk 5 жыл бұрын
n-1
@shobhitranjan3957
@shobhitranjan3957 4 жыл бұрын
BRILLIANT PLAYLIST THANK YOU!
@dzmitryk9658
@dzmitryk9658 5 жыл бұрын
Thank you! A great explanation. I keep coming to your videos from time to time. lol
@dhruvashah3161
@dhruvashah3161 9 жыл бұрын
Thanks a lot!!! It really help me to understand concept of all sorting algo very easily..
@DenisG631
@DenisG631 9 жыл бұрын
+mycodeschool thanks for the video! Could you please post the link you are mentioning at 18:39 ?
@divyarthsingh4001
@divyarthsingh4001 5 жыл бұрын
Annihilation condition for worst case, where you've written "n-k=1" is right, but further equated to 'k=n' is a mistake, "k=n-1" is correct. This might bring some difference in the final equation but complexity remains the same n.log(n)
@zannylover2898
@zannylover2898 5 жыл бұрын
just aweshome,great sir,come again on youtube sir
@jp-wi8xr
@jp-wi8xr 9 жыл бұрын
14:30 n-k = 1; k=n ( should be n-1 )
@prashantbalana7230
@prashantbalana7230 9 жыл бұрын
+Piyush Jaiswal if u 'll put k=n-1 ,then also the complexity 'll come-O(n*n), SOLUTION- T(1)+(n-1)*c*n -(n-1)*(n-2)*c/2 c + c2(n*n - 5*n +2) cn*n-5*c*n+2 =O(n*n) Hope it explains...
@sajalgoyal1094
@sajalgoyal1094 4 жыл бұрын
maybe k and n are both much much larger so k approximately equals n
@dhruvneo
@dhruvneo 3 жыл бұрын
Just wanted to say, amazingly explained. One query though, at 14:28, it is explained n-k = 1 , so k = n. This seems right? So either base case should T(0) or calculation will be made for k = n-1.
@heisenberg_737
@heisenberg_737 5 жыл бұрын
At 18:24, either it should be summation from i=1 to n instead of i=0 to n, or if the limit is from i=0 to (n-1) then T(i) + T(n-i-1) should be written btw nice lecture.
@rishabhsinha44
@rishabhsinha44 11 жыл бұрын
i think while finding time complexity in worst case ,for generic expression when n-k=1 then n=k+1 or k=n-1..
@jlb20001
@jlb20001 10 жыл бұрын
i think that too.. finally what's the deal here..? have you figure out..?
@ttenodi
@ttenodi 10 жыл бұрын
yea, that's truth, but it doesn't matter that much, because the greatest element in polynomial will still be n^2.
@AnkitKumar-zu7cn
@AnkitKumar-zu7cn 7 жыл бұрын
fair thought....but the twist is, for a very large value of n : n-1 -> n
@mohammadmujahid8850
@mohammadmujahid8850 5 жыл бұрын
Thank you for sharing such a great knowledge.
@anaganisaiteja9061
@anaganisaiteja9061 8 жыл бұрын
thank you sir...these videos are really awesome. but sir please make video on shell and heap sort.
@subashraj3919
@subashraj3919 3 жыл бұрын
Good and clear Explanation.. Thank you..
@BhargavJhaveri
@BhargavJhaveri 9 жыл бұрын
@mycodeschool: Could you please provide a link to the Average case mathematical analysis?
@moon.0_0
@moon.0_0 4 жыл бұрын
Hey, I just wanna tell u that u did great job ... But I want u to cover up heap sort(imp) and other sorting algorithms as well.
@armandoantoniogarduno4969
@armandoantoniogarduno4969 6 жыл бұрын
What if we use the "median 3" value as a pivot? We get three values from the subarray: The first, last and middle elements. Then we check the 3 values and determine which one is in the middle. Let's say that the elements are 4, 9 and 1, the element in the middle is 4, and we use that as our pivot. Then, we can re-arrange the elements: 1, 4, and 9 before subdivide the array.
@babysuyash
@babysuyash 3 жыл бұрын
Yeah we can do that the median of 3 will have same complexity as the lomuto or the partition shown in the video ...but median of 3 will run faster it decreases some constants and also one could always use random pivot to not get the constant and settle in the average case...and I think we only have ways to prevent to get worst case for quicksort..I don't think we can somehow change the complexity of the worst case for the quicksort....For better time complexity one could always take 2 pivot points, as It is found more the pivot point the quick the quicksort will work but if one encounters worst case for quicksort the complexity would always be O(n^2)
@raghurambharadwaj
@raghurambharadwaj 11 жыл бұрын
a big thanks to you sir....Great explanation.
@kartaLaLa
@kartaLaLa 8 жыл бұрын
your video is extremely good for understanding :D!! please record more sorting algorithm :D
@josejerry5546
@josejerry5546 10 жыл бұрын
thank u so much. it was really understandable. especially it gave me some confidence regarding code implementation.
@volkanulker6432
@volkanulker6432 3 жыл бұрын
14:31 why n-k=1 => k = n Can someone explain this to me ?
@ajayshah6978
@ajayshah6978 9 жыл бұрын
can u upload videos on heap sort and radix sort asap plz?? btsw excellent explanation..
@amitmahto68
@amitmahto68 9 жыл бұрын
+mycodeschool can you please explain how the given program for quicksort is not stable??? I have tried to take examples but I am still not getting it??
@w4h175
@w4h175 3 жыл бұрын
this person is god at teaching..
@darshitamistry
@darshitamistry 11 жыл бұрын
Thank you so much for very descriptive video on Quick sort. Please can you post a link for mathematical solution of T(n).
@stardust3579
@stardust3579 4 жыл бұрын
great explanation 👍👍👌
@usama57926
@usama57926 6 жыл бұрын
you are great mathematician bro thanks
@manavmohata1240
@manavmohata1240 5 жыл бұрын
What if we took the random index from 1 to n-2as it will then never choose the last and first element?
@asishcodes
@asishcodes 2 жыл бұрын
Can someone please explain me how he has done that math in 13:11
@vinayak186f3
@vinayak186f3 4 жыл бұрын
I have a doubt , would that randomized qs be at all effective ? since eventually , we are just shifting that random value to the end , that is also a random value .
@Utkarshkharb
@Utkarshkharb 3 жыл бұрын
It doesn't matter where the pivot is placed. The value of the pivot matters. We are trying to avoid possibility of choosing the largest or smallest value in the array as the pivot, since that would lead to a skewed partitioning. By choosing the pivot randomly from the array, we are making sure that doesn't happen. Since choosing a non-extreme value is much more probable than choosing an extreme value, this approach is v effective. Shifting the pivot value to the end of the array just makes sure we can retain the same code we wrote if we just chose a pivot from the end :)
@sabesansp
@sabesansp 10 жыл бұрын
Good stuff !!! Loved the font... Can u post what application you used for writing and capturing the video ?
@mycodeschool
@mycodeschool 10 жыл бұрын
Sabesan Saidapet Pachai blog.mycodeschool.com/2013/11/how-to-create-amycodeschool-style-video.html
@javsolo
@javsolo 6 жыл бұрын
At 14:53, shouldn't k = n-1?
@raibahadurdiljale5914
@raibahadurdiljale5914 5 жыл бұрын
Yes, it is a typo but for calculating Big-O notation it is still n-square (n^2) terms.
@mrdedhia
@mrdedhia 3 жыл бұрын
yes, it should be n-k=0, hence k=n
@anupamjoshi224
@anupamjoshi224 10 жыл бұрын
awesome video....nicely explained
@PeterXyzdlv
@PeterXyzdlv Жыл бұрын
What if we take pivot as (start + end)/2?
@karankapoor2116
@karankapoor2116 10 жыл бұрын
sir would you please give the link to time complexity analysis in randomized approach for the sort ?
@sciproject1
@sciproject1 9 жыл бұрын
mycodeschool your videos are amazing please can anyone explain me that how random no. is chosen as pivot.I understood that another function is made for this purpose but how will this function work?
@ridakhan7245
@ridakhan7245 9 жыл бұрын
+Yastika Kumar This won't be a function you write. Instead, you'll be using the language's random generator function. Just look that up.
@tomasz-rozanski
@tomasz-rozanski 8 жыл бұрын
That was quick analysis of the quick-sort, ladies and gents.
@kautukraj
@kautukraj 5 жыл бұрын
Very helpful!
@leharbhandari6852
@leharbhandari6852 10 жыл бұрын
Wow! What an awesome video! :D
@yogitajain8003
@yogitajain8003 3 жыл бұрын
Till date i just heard about randomized partition but didn't know now i got it
@anithavikkiraman709
@anithavikkiraman709 9 жыл бұрын
amazing videos thanks a lot will you help me with radix and shell sort algorithms
@shashwatsrivastava4150
@shashwatsrivastava4150 11 жыл бұрын
your videos are awesome !! more algos plz ...
@user-fk8wq9dx4c
@user-fk8wq9dx4c 9 жыл бұрын
Great tutorial . Thanks
@sakshikochharnonu
@sakshikochharnonu 9 жыл бұрын
if the Array is {2,7,1,6,8,5,3,4} then how will it work-> 'Pindex' and 'i' will have same values all through the loop Please help
@RohitSingh-bw1fo
@RohitSingh-bw1fo 8 жыл бұрын
pindex will be incremented only if a[i] will be smaller than the pivot element i.e 4 in your case whereas i will be incremented after every element.
@keerthi6luvmyguitar
@keerthi6luvmyguitar 6 жыл бұрын
No it will not.
@cpwithsundar
@cpwithsundar 4 жыл бұрын
i will have the same value only at first position . and then the first swap is just like swap(2,2)....which can be avoided with giving condition like if(i!=PIndex) swap(A[i],a[PIndex]);
@arkadeep8049
@arkadeep8049 5 жыл бұрын
8:22 Instead of a, I'll write c, because c looks good, when I am saying its a constant.... XD
@asishcodes
@asishcodes 2 жыл бұрын
BEST VIDEO EVER
@The-pf4zy
@The-pf4zy 8 жыл бұрын
Can you do the gravity sort next?
@chitrarajshekar3003
@chitrarajshekar3003 4 жыл бұрын
Heap sort and radix sort algorithms?
@kamanakhanal9700
@kamanakhanal9700 10 жыл бұрын
thank you so much fr this tutorial.. bt plz can u help me with randomized quick sort time complexity calculations??
@learnjava6249
@learnjava6249 9 жыл бұрын
Expressing T(n) in terms of T(1) , in that case n/2^k = 1. Can you please explain this?
@ridakhan7245
@ridakhan7245 9 жыл бұрын
At each step n is being divided by 2 to get n/2, then n/4, then n/8 and so on. In general it is T(n/2^k) with k being the number of times we've done that division. (Try this out for different values of k if you find it confusing) We want to take that expression to the base case of T(1) at which point n/2^k = 1. Hope this helps.
@ramarao_amara
@ramarao_amara 6 жыл бұрын
What's wrong in my code int arr[]={4, 5, 6, 2, 1, 7, 10, 3, 8, 9}; int size=sizeof(arr)/sizeof(arr[0]); quickSort(arr, 0, size-1); void quickSort(int arr[], int low, int high) { if(low>=high) return; int partionIndex=randmized_partition(arr, low, high); quickSort(arr, low, partionIndex-1); quickSort(arr, partionIndex+1, high); } int partition_arr(int arr[], int low, int high) { int pivot=arr[high]; int partionIndex=low; for(int i=low;i
@asishcodes
@asishcodes 2 жыл бұрын
How he written the equation in 18:22
@chunaramgodara8016
@chunaramgodara8016 9 жыл бұрын
please upload a video on heap sort using c++
@mayankgupta5658
@mayankgupta5658 8 жыл бұрын
where is the math of calculating the average case complexity i was not able to find it
@100Ticks
@100Ticks 9 жыл бұрын
t(n) = 2{2T(n/4) + c.n/2} + c.n Why do you have the extra c.n?
@manavmohata1240
@manavmohata1240 5 жыл бұрын
Because of partition function
@yashranka5597
@yashranka5597 8 жыл бұрын
plz make a video on heap sort also
@samyouaret5622
@samyouaret5622 7 жыл бұрын
the narrator is alife , his friend who is dead .
@SanaMalik-ss3sh
@SanaMalik-ss3sh 9 жыл бұрын
Can u plz upload the code implementation of "Merge Sort" also plz..........
@amritansh92
@amritansh92 8 жыл бұрын
if n-k=1, then how is n=k? it should be k=n-1. at time 14.33
@mrdedhia
@mrdedhia 3 жыл бұрын
yes, it should be n-k=0, hence k=n
@pavanipriyanka105
@pavanipriyanka105 7 жыл бұрын
please post a video on heap sort
@haseebsohail8126
@haseebsohail8126 9 жыл бұрын
Great, you helped me a lot. :)
@giannisdimaridis2920
@giannisdimaridis2920 9 жыл бұрын
Really helpful, thank you.
@JayKumar-qy3ke
@JayKumar-qy3ke 8 жыл бұрын
please,upload heap sort.
@md.nahidulalamchowdhury9568
@md.nahidulalamchowdhury9568 2 жыл бұрын
Thanks. k will be n-1 not n at 14:30
@aashitgarodia
@aashitgarodia 7 жыл бұрын
Please do SHELL SORT and HEAP SORT
@SumitKumar-fn3gj
@SumitKumar-fn3gj 5 жыл бұрын
🤓🤓
@krishnaveniperam4955
@krishnaveniperam4955 3 жыл бұрын
wow explanation. Thank you
@matitiudeforever8155
@matitiudeforever8155 6 жыл бұрын
well done !!
@chandrahas2567
@chandrahas2567 5 жыл бұрын
why space complexity is o(logn) for quick sort
@NgaNguyen-th3jx
@NgaNguyen-th3jx 4 жыл бұрын
chandrahas kondle its memory taken for recursion.
@pritamsarkar8830
@pritamsarkar8830 8 жыл бұрын
how is it possible..... if n-k=1; then n=k;???????
@jishanshaikh7123
@jishanshaikh7123 7 жыл бұрын
1 can be neglected
@jishanshaikh7123
@jishanshaikh7123 7 жыл бұрын
n=k+1 n=k where 1 is neglected because of high value of n
@vivekrmishra
@vivekrmishra 6 жыл бұрын
where is space complexity analysis?
Quicksort algorithm
20:39
mycodeschool
Рет қаралды 1,8 МЛН
Best Case Analysis of Insertion Sort
12:48
CS Simplified
Рет қаралды 7 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Analysis of Merge sort algorithm
18:21
mycodeschool
Рет қаралды 549 М.
FASTEST sorting algorithm. Ever! O(N)
9:41
Gaurav Sen
Рет қаралды 871 М.
Time complexity: Best and Worst cases | Quick Sort | Appliedcourse
15:40
GATE Applied Course
Рет қаралды 75 М.
2.8.1  QuickSort Algorithm
13:43
Abdul Bari
Рет қаралды 3,4 МЛН
Merge sort algorithm
18:20
mycodeschool
Рет қаралды 2,2 МЛН
Every Sorting Algorithm Explained in 120 minutes (full series)
1:57:33
Kuvina Saydaki
Рет қаралды 82 М.
Learn Quick Sort in 13 minutes ⚡
13:49
Bro Code
Рет қаралды 435 М.
Selection sort algorithm
10:18
mycodeschool
Рет қаралды 1,3 МЛН
6. Randomization: Matrix Multiply, Quicksort
1:21:52
MIT OpenCourseWare
Рет қаралды 63 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН