This is great video! but, I feel the algo provided in the end is not the same as the way he was explaining.. I went ahead and wrote my code for it same way he explained: ``` class Solution: def sortArray(self, nums: List[int]) -> List[int]: def quicksort(nums, lo, hi): if lo < hi: partition_resting_point = partition(nums, lo, hi) quicksort(nums, lo, partition_resting_point - 1) quicksort(nums, partition_resting_point + 1, hi) def partition(nums, lo, hi): pivotIdx = random.randint(lo, hi) nums[pivotIdx], nums[hi] = nums[hi], nums[pivotIdx] pivot = nums[hi] l_idx = lo r_idx = hi-1 while l_idx
@MichaelSambol2 жыл бұрын
Yeah, in the early days I didn't spend enough time on pseudocode. Trying to fix that now by building out this repo: github.com/msambol/youtube/blob/master/sort/quick_sort.py. Thanks for the feedback!
@westsideslasha2 жыл бұрын
@@MichaelSambol I got really confused when the pseudocode didn't match the explanation. You should correct that (in the video) ASAP.
@MichaelSambol2 жыл бұрын
@@westsideslasha I'm sorry about that! KZbin won't let me change the video now unfortunately, but I pinned this comment.
@manavshah4482 жыл бұрын
I am encountering an infinite loop if I change the while condition to be i < j instead of
@amono770 Жыл бұрын
i am glad that i looked at the comment section after having a hard time connecting the pesudo code to the video content.
@EchoVids2u4 жыл бұрын
With every new quick sort video, I watch, I get more recursively confused.
@Iceron554 жыл бұрын
same lol all the quicksort videos use the same words to explain it
@अनिष्टदेव-श7य4 жыл бұрын
hey man, after pulling my hair out for 2 days I finally got it, sadly I had to pay for it.
@HACKINGMADEFUN4 жыл бұрын
@@अनिष्टदेव-श7य what did u pay for?
@अनिष्टदेव-श7य4 жыл бұрын
@@HACKINGMADEFUN a Udemy course
@HACKINGMADEFUN4 жыл бұрын
@@अनिष्टदेव-श7य cool
@jonahrivera74 жыл бұрын
Guy: "I think you understand the concept" Me: No I don't
@Evokans3 жыл бұрын
it gets halved and is recursively applied to both halves in each step
@sleevman3 жыл бұрын
@@Evokans um what?
@faith27563 жыл бұрын
@@sleevman It gets repeatedly done on each new half, as after each half the pivot is in the right place, so a new pivot is used.
@sleevman3 жыл бұрын
@@faith2756 sorry wat?
@faith27563 жыл бұрын
@@sleevman Which part exactly do you not understand?
@SAMURAIch4 жыл бұрын
I feel so dumb when i don't understand this, but then i just scroll the comment section and realise that im not alone lol
@liuqing19953 жыл бұрын
understanding the meaning of pivot is the KEY.
@reguret2976 Жыл бұрын
yeah, theitemfromleft, or right wasn't even properly discussed, left of what or right of what exactly?
@skyness99 ай бұрын
lol
@anshulsharma94244 ай бұрын
he is missing lot of steps , this video is a crime
@moonasha2 ай бұрын
that's because it's explained horribly in this video
@alanfender1235 жыл бұрын
i should be working at mcdonalds
@SkillUpMobileGaming5 жыл бұрын
You really should. *SAD!*
@IStMl5 жыл бұрын
@@SkillUpMobileGaming You too
@torment64254 жыл бұрын
wait what. why
@asailingstone4 жыл бұрын
lol 😂😂😂
@web-unlocked4 жыл бұрын
that's what I was thinking. you're a genius pal
@yufangjuan49943 жыл бұрын
To ones without enough background knowledge, this video omits details of execution of each step. But to ones with, this is concise and covers sufficient key points of quick sort. Thanks a lot for your video sharing.
@noahdirksen36233 жыл бұрын
Thats the fanciest wording I've heard, i would use: "You get it or you dont"
@Seanz2088 Жыл бұрын
Try to sort a few short sequences yourself according to the steps in the video. You may get the "background knowledge".
After you swap itemFromLeft and the pivot at the end, itemFromLeft is now at the end of the array. So, use that as the *new* pivot. Repeat that until its sorted.
@kennethquilantang80805 жыл бұрын
@@airex12 so 8 is the new pivot? How can I go through if there is no number in the array greater than 8?
@airex125 жыл бұрын
@@kennethquilantang8080 after 7 is put in its correct position, remember that all numbers to the right of 7 are greater than 7. In this case, there is only one number - 8. A partition with just one number is already sorted, so you can ignore it and move on to sort [6,5] to the left of 7. For sorting [6,5] choose 5 as the pivot. itemFromLeft is therefore 6, and itemFromRight has no value because no number in the array smaller than 5. Therefore, we can stop and swap itemFromLeft and the pivot to leave [5,6]. Yes, the video is unclear because it does not explain these cases. The point is that each time you put the pivot into it's correct position, you have "split" the array into two parts - one part has all numbers bigger than the pivot and the other part has all numbers smaller than the pivot. Parts with *just one* element are already sorted. If a part is already sorted, no itemFromLeft can be found. If a part is unsorted, you are guaranteed to find an itemFromLeft, and if the index of itemFromRight < the index of itemFromLeft *OR* itemFromRight does not exist then you can swap itemFromLeft and the pivot to put the pivot into its correct position in the whole array.
@kennethquilantang80805 жыл бұрын
@@airex12 I get your point bro thanks but what would be the next step. Will I need to pick another pivot? How can I sort the rest?
@Charoula16086 жыл бұрын
*screams in Ross voice* PIVOT! PIVOT! PIVOT!
@peizhiyan29166 жыл бұрын
haha, I can't help imaging Ross's face, hahaha
@Daver22125 жыл бұрын
Me in future, oh Ross's couch sort?
@Jiwoo155 жыл бұрын
screams in Chandler voice SHUT UP! SHUT UP! SHUT UP!
@mahnazha5 жыл бұрын
Oh my GOOOOD :-))))))))))))) So truuuuueeeeeee
@AbdelhameedG5 жыл бұрын
This is exactly what came into my mind learning about this :))
@theducksneezes49874 жыл бұрын
How to get Confused in 4 minutes then again, this was the best video about it so far
@4TH4RV4 жыл бұрын
I want more videos like this where they explain stuff in less than 10 minutes
@omegagmysta20924 жыл бұрын
Bet ? kzbin.info/www/bejne/kJmWaIuvhrF7odk
@JoelThomas-sr6ti8 ай бұрын
there's a video by abdul. i think it is best
@hakmat1769Ай бұрын
there is better ones
@emilgebl86444 жыл бұрын
If anyone is confused at the 1:10, basically he doesn't go through the loop. Instead he jumps to when item from left is higher or item from right is smaller etc. There is a left and right pointer that checks for the condition and then left++ or right-- if its not correct. itemsfromRight goes from 1 cuz its smaller, and then the right-- checks 7, not smaller, right--, checks 8 not smaller, right-- and then it checks the 0 and see that its smaller.
@christianeichmueller86372 жыл бұрын
Thanks for the explanation!
@jamboy18432 жыл бұрын
what the hell are you talking about this is a church sir
@emilgebl86442 жыл бұрын
@@jamboy1843 I don't even remember making this comment.
@wendyd.19183 жыл бұрын
I study computer science, and once, I had an exam with a few sort algorithms in it. I didn't really study but about twenty minutes before the exam I watched your 2-4 minute videos on these sort algorithms and I passed the exam. Thank you for helping me.
@fireboywatergirl1625 Жыл бұрын
thats gonna b me td lmao
@wendyd.1918 Жыл бұрын
@@fireboywatergirl1625 i am sure you are at the right place.
@LGNNorotic4 жыл бұрын
you should put the code next to all of the visual aids and highlight each line as its being done in the visual. thanks for the help with sorting!
@LL-rn8rn6 жыл бұрын
The psudocode is not intuitively reflecting the walkthrough
@diabl2master5 жыл бұрын
I've been looking at it for a few minutes now, and I can believe that this pseudocode is accurate, but I'd have to check the details of what the partition function is doing to be sure, but it seems legit. Assuming your language of choice will permit a self-referential function like that.
@jscholex4 жыл бұрын
@@diabl2master The recursion is fine... he's talking about how `partition` is putting the pivot on the left wall instead of the right. In the video the pivot is on the right side.
@diabl2master4 жыл бұрын
@@jscholex That would be a failure of technically reflecting, not intuitively reflecting, the walkthrough. I'm not sure OP was referring to that, but who knows.
@jscholex4 жыл бұрын
@@diabl2master Yeah who knows... but I think we can all agree the pseudocode isn't great hah
@skarfie1233 жыл бұрын
the pseudocode shows the Lomuto version but the visualisation is for the Hoare version, which is better. See Wikipedia for both.
@yessirski78689 ай бұрын
people are complaining but this is gonna come in clutch for my wirtten exam tmr.
@fr52297 жыл бұрын
This is great. The simple explanation and the especially simple pseudocode towards the end makes it easy to understand the core concept of the algorithm.
@nabe43207 жыл бұрын
am still confused
@ibu4336 жыл бұрын
N Betancourt cuz the way he explains it IS confusing I’ve watched this a couple of times, thought I understood went to the exam and screwed up Now that I’ve watched other videos I understand that the way he explains it is confusing
@thewiseowl88045 жыл бұрын
N Betancourt He made it more confusing, for sure.
@diabl2master5 жыл бұрын
He didn't explain what quick sort does in general, what it can be applied to, and left some holes in the explanation that someone with no experience would struggle to grasp. Which is a shame.
@omegagmysta20924 жыл бұрын
Hope this helps :kzbin.info/www/bejne/kJmWaIuvhrF7odk
@alvin_row4 жыл бұрын
i hope you got it cute bird from nichijou
@ToriliaShine2 жыл бұрын
thank u so much, i have an exam tommorow and was stressing bc i couldnt figure out how quick sort work with my teacher's explanation and this just simplified it easily. tysm ;-;
@AushHegde-om9xv Жыл бұрын
The video explains the concept of quicksort, a recursive algorithm used for sorting arrays. It emphasizes the importance of choosing a pivot and demonstrates the process of partitioning the array. The video also mentions the pseudocode for quicksort and discusses its time complexity. Understanding Quicksort Algorithm 00:00 Quicksort is a recursive algorithm that uses a pivot to sort an array. 00:13 The pivot is placed in its correct position, with smaller items to the left and larger items to the right. 03:24 Choosing the pivot properly is crucial for the performance of the algorithm.
@Shivam25Verma3 жыл бұрын
Thank u very much Sir, I got it completely. Actually I'd missed my college online lecture b/c of sleeping... U saved me just night before exam, as urs is the shortest video on YT.
@Woopinah3 ай бұрын
Very very good video, thank you! I really love how you never stutter over your words, and never say uhm or uhhhh. That makes this very easy to watch.
@godaimer9993 жыл бұрын
explained it much fckin better in 4 minutes with 1.5x watchspeed than my teacher in a 90 minutes class, thank you sm
@matedominguez2883Ай бұрын
Great series man! This week is my Algorithms II exam and these helped me. Keep it up :)
@brianmartinez61933 жыл бұрын
I watched several videos, including my school books, and I had no idea what they were saying with left to right and could not get the answers in the correct order because of that. I was able to understand after watching your video and it allowed me to get past my assignment. Thank you.
@MewPurPur3 жыл бұрын
Yess I finally understood it, having a clear mind the morning before the exam helped
@gm130s2 ай бұрын
4:03 In the Partition func, `low` never gets modified so the `for` loop would deadlock. In the Python example linked from this video it uses `range` that increments so the loop won't deadlock. Sorry if this is duplicated info.
@sachinpathy69403 жыл бұрын
i put this at 1.5x and now i learnt quick sort 2.6667 minutes
@IOSALive9 ай бұрын
Michael Sambol, You're amazing! Let's be friends and have fun together!
@ganimatormusic2 жыл бұрын
Thank you so much, i have a pc science test today, and i didn'T understand since i can't speak german that well and i am still learning it, this guy explained it all
@atmajoburman73354 ай бұрын
better and much easier algo than any standard quicksort algo available in the books
@nemesis94105 жыл бұрын
This is the most confusing and incoherent visualization of quicksort I've ever seen
@thewiseowl88045 жыл бұрын
Well said 👍
@ChristianMay215 жыл бұрын
Makes perfect sense to me
@thewiseowl88045 жыл бұрын
Christian May That’s so great! 🙌👏
@diabl2master5 жыл бұрын
I thought the visualisation was fine. I feel that I understand it now.
@cristian-bull4 жыл бұрын
This is the fist visualisation of quick-sort I've ever seen, so I know it doesn't mean much, but I agree.
@seltonmc3 жыл бұрын
Your short videos helped me a looot. Thank you so much!
@chinmayhattewar44564 жыл бұрын
Imagine newcomers watching this explanation for the first time.
@BethanyLowe87733 жыл бұрын
Thank you. I feel the same about my actual online course I'm studying. And I'm a newcomer. I feel better.
@krishnarajj93583 жыл бұрын
horrible
@csstudent7175Ай бұрын
I wish the video was longer… You explained quite well, but I would love to learn more about the details that you didn’t get a chance to cover.
@snake32761203 жыл бұрын
LOL this is one of the best and easiest video out there on quick sort. All of you disliking it shouldn't do programming.
@mehdibadaoui16585 жыл бұрын
when i search for something on youtube and see one of your videos in the results i genuenly get excited
@lemonw39064 жыл бұрын
The pseudocode is hard to read, but the variable name "leftwall" is really good, this gives me a vivid concept of how the leftmost larger item was swapped and the "wall" moved.
@hiteshsahu_2 жыл бұрын
pseudocode is actually wrong as well !
@blurryhorizon2 жыл бұрын
@@hiteshsahu_ Exactly, not only 1 pointer moves & stopping when this 1 pointer reaches end of the array, but also only picking leftmost value as pivot
@Kokil923412 жыл бұрын
@@hiteshsahu_ Exactly , i have wasted so much time over it
@scarlettwang21462 жыл бұрын
@@blurryhorizon I suppose that in the Partition function, the "pivot = A[low]" should actually be "pivot = A[high]"? Very confusing so I wrote it down and found out that the pseudocode doesn't work properly. // Oh just realised that although pivot = A[low] might works as well but the pseudocode is totally wrong for Partition function jeez..
@kemot25 Жыл бұрын
@@scarlettwang2146 I think it should be as it is. Something else is wrong.
@Kleyguy73 жыл бұрын
I think I'm here for the fourth time now.
@HelloWorld-tn1tl3 жыл бұрын
This is the first video that made me really understand how to impl quicksort, and it's very short.
@dh72228 жыл бұрын
These are some clean tutorials. Thank you for making this!
@smbowner10 ай бұрын
Hey, Thanks for the explanasion, It was a clear and concise video, however the pseudocode is somewhat wrong I believe in 3 things: In Partition, the order of operations is not correct: increment leftwall first, then swap. The final swap in Partition is not correctly swapping the pivot's original position with A[leftwall]. The recursive calls in Quicksort should be updated to exclude the pivot_location from the ranges, properly dividing the array into segments that exclude the sorted pivot. here is the corrected version: Quicksort(A as array, low as int, high as int) if (low < high) pivot_location = Partition(A, low, high) Quicksort(A, low, pivot_location - 1) Quicksort(A, pivot_location + 1, high) Partition(A as array, low as int, high as int) pivot = A[low] leftwall = low for i = low + 1 to high if (A[i] < pivot) then leftwall = leftwall + 1 swap(A[i], A[leftwall]) swap(A[low], A[leftwall]) return(leftwall) Thanks again!
@devanshityagi82315 жыл бұрын
Wow... You just found a place in my mind where you stored quick sort so deeply.🙋💖😂
@DT-ll8og2 жыл бұрын
Thanks for clear explanation. Correct Position for Pivot, let recursive do remains. Good job man.
@parthpatel-bt7qw7 жыл бұрын
This was exactly the kind of video I was looking for!! Short and concise, but no loss of information. Thank you.
@M15onehundred5 жыл бұрын
Nice! Glad to see magic still exists!
@Brooklyn-nk9by Жыл бұрын
Love the videos!
@Guy19372 Жыл бұрын
Haha you copied me! Very funny feel like a real bogo sort right now
@J4T3754 жыл бұрын
all your videos are short and very useful.
@ragavendhart6 жыл бұрын
I guess, In the quicksort explanation he moves the pivot to the RIGHT END of the array. In the pseudocode, he moves the pivot to the LEFT end of the array. And after the swapping is done, he then brings the pivot to the original position from the LEFTEND. I've seen too many quicksort algorithm videos and this works the best for all my cases.
@okaydayy4 жыл бұрын
That is the exact! same Quick Sort Algorithm we have been thought. Really good! Thanks
@mirana76602 жыл бұрын
it's 8:48 AM, i have an exam at 15:30 PM and ur saving me here
@akira_asahi2 жыл бұрын
Thank you for the video. I am grateful for your time and contribution. Kind regards, Akira.
@prohakerofficial6 ай бұрын
Very good video, I learned quick sort easily thanks to this. Although, I did have to rewatch the "median-of-three" explanation.
@liormoreh83135 күн бұрын
Best Quick Sort video ive ever seen!
@noddycode73245 жыл бұрын
QuickSort has always been a bit of a mystery to me, but somehow this video instantly made it click. Thank you so much!
@senaszel4 жыл бұрын
Helped me. Great vid. Fan of your since now. Cheers.
@baribari6004 ай бұрын
"let's let recursion handle the rest" > "here's the rest of the owl"
@SarveRadhaNaam2 жыл бұрын
don't you think at 4:04 , in Partition code. leftwall++ should be before swap(A[i], A[leftwall])
@Crzynoob5 жыл бұрын
Psuedo code does not match demonstrated algorithm.
@powergaming28832 ай бұрын
There was quiet a bit of sigma in this video wouldn't you say my fellow skibidis?
@Athanas0075 жыл бұрын
0:10 who else thought of Ross screaming Pivot from that Friends Episode
@lil-mi-7772 жыл бұрын
The video hold the key of quicksort, most clear to me!
@arminkrahbar2 жыл бұрын
The visualization is perfect!
@davidrichmond97596 жыл бұрын
These 4 minute videos are great for cramming!
@reytampubolon63902 жыл бұрын
currently studying for my Algorithms and Data Structure exam, your video is very helpful :) thanks
@AaryanDhand10 ай бұрын
thank you so insightful :)
@AaryanDhand10 ай бұрын
me too
@AaryanDhand10 ай бұрын
yo me too
@yahiashams23343 жыл бұрын
That without voice over made the video from great to perfect
@SuperJosba2 жыл бұрын
Perfect explanation of quick sort!!
@CompilerStuck2 жыл бұрын
I can now finally sort my life out
@jola_mir83273 жыл бұрын
Grate video! Just one thing. @ 1:53 itemFromLeft is 0 and itemFromRight is 5. This part confused me.
@jeffchai65613 жыл бұрын
This algo is akin to a toddler randomly sorting numbers around until they're in order
@Tracing00294 жыл бұрын
This will be useful for tomorrow's exam.
@user-fc5ou7pn2k2 жыл бұрын
amazing, ive got an exam tmrw... this lesson is much appriciated as my professor is not very good at explaining these basics
@Rglezy3 жыл бұрын
FINALY SOMEONE WITH CLEAR INSTRUCTIONS
@VictorBanerjeeF5 жыл бұрын
Thanks Brother, You save my 10 min exam fast revision time
@miso-ge1gz Жыл бұрын
i cannot even describe how much i hate learning these, thanks for the video it helps a lot
@inco__gnito__channelАй бұрын
I think we should pick the pivot and start comparing , value at i and pivot value not pivot is shifted at last.index and keep swaping based on element values Pseudo Code : QUICKSORT(A) 1: if A is empty then 2: return A 3: last← (length(A) − 1).index 4: pivot ← A[last] // Take last element as pivot 5: less ← {A[i] | A[i] ≤ pivot, i != last} 6: more ← {A[i] | A[i] > pivot, i != last} 7: return (QUICKSORT(less), pivot, QUICKSORT(more))
@Carl-Gauss9 ай бұрын
4:11 I think the more precise way to put would be not “chosen properly” but instead “we don’t get very unlucky”.
@karaqore2 жыл бұрын
Hvala ti brate pomogao si mi puno u životu
@MauricioVonB3 күн бұрын
I liked it, a clear and complete video. Thanks a lot :)
@Jack-dx7qb5 жыл бұрын
Why the pseudocode doesn't intuitively reflect the walk through? (Quote from Wikipedia) "The pivot selection and partitioning steps can be done in several different ways; the choice of specific implementation schemes greatly affects the algorithm's performance." There are two partition schemes: 1. Lomuto partition scheme, which is the pseudocode provided in the video. 2. Hoare partition scheme, which is the walkthrough in the video. Comparison (Quote from Wikipedia) 1. "As the Lomuto partition scheme is more compact and easy to understand, it is frequently used in introductory material, although it is less efficient than Hoare's original scheme." 2. "Hoare's scheme is more efficient than Lomuto's partition scheme because it does three times fewer swaps on average, and it creates efficient partitions even when all values are equal." To understand the Lomuto partition scheme more, I recommend a KZbin video called "Quicksort: Partitioning an array" by KC Ang.
@ggg-tq9be3 жыл бұрын
thank you a lot!
@haloum2 жыл бұрын
this made it a lot more logical for me, thank you.
@chetanphoenix4 жыл бұрын
I really like this explanation. This moves the pivot out of the way and swaps it back with the itemFromLeft pointer. That's so much easier than some other videos I've seen where the pivot is in the middle of the action and we're confused with >= or
@ggg-tq9be3 жыл бұрын
yes! It is cool!
@mitchross40022 жыл бұрын
God bless you man this is by far the most straightforward and comprehensible explanation of quicksort, really got me out of a pickle with this one.
@MichaelSambol2 жыл бұрын
God bless, Mitch
@nolanrudolph54635 жыл бұрын
I feel like the pseudo code would reflect the presentation a lot more if we let pivot be A[high] with rightwall=high-1. Then the conditional statement to initiate swap would be if(A[i]>pivot), and of course having rightwall=rightwall+1
@mekabare11 ай бұрын
I'm seeing myself working customer service for the rest of my life
@saranyabalasubramanian4452 ай бұрын
My prof taught me this is in like 1 hour(nothing reached to my braincells)but this 4 minutes taught me well ☝️
@jarencascino78624 жыл бұрын
This is exactly what I was looking for in a video
@alanperaza56964 жыл бұрын
It was quick and I understood everything. Thanks a lot
@고구마-q9l5 жыл бұрын
my professor is horrible at explaining this so I had to find a youtube video about quicksort and teach myself
@SunsetsOverBatteryCity8 ай бұрын
Him: “quick sort = pivot” Me: “WHILE HE HID IN RADIO WE PIVOTED TO VIDEO 🗣️💥”
@MuggL7 ай бұрын
Your videos are busteling always, keep cooking!
@campermortey7 жыл бұрын
I'm a little confused. In your very detailed, and helpful, explanation of itemFromLeft and itemFromRight it makes total sense. It is similar to the method Gayle uses in her QuickSort video to keep going and swap left and right having both points meet each other. Your implementation, however, seems to go a completely different route by using a for loop with only one pointer and swapping with a wall, similar to Harvard's CS50 class on QuickSort. Also, I found your code kinda confusing by swapping the values and not indexes. I had some problems running that code. My partition looks like this: public static int Parition(int[] array, int left, int right) { // Make starting pivot the last one for now int pivot = array[right]; int leftWall = left; // Go through array until index is reached for (int i = left; i < right; i++) { // If item at array[i] is less than or equal to pivot then switch with leftwall if(array[i]
@samimulaw6 жыл бұрын
i am confused too
@ragavendhart6 жыл бұрын
Gayle's video doesn't work for a few cases. This explanation is perfect and works like magic. Great job!
@icxonrus6 жыл бұрын
This video uses Lomuto partition scheme while Gayle uses Hoare. They are both valid, and Hoare is faster for some cases, see wiki for more info.
@jaymiracle55005 жыл бұрын
For those who are not understanding the pseudo code, here is the code that matches the demonstration: private static int partition(int[] arr, int low, int high) { int itemFromLeft = low, itemFromRight = high, pivot = arr[high]; while(itemFromLeft < itemFromRight) { //you need the second condition for the rare case where the pivot is the largest while(arr[itemFromLeft] = pivot && itemFromRight != low) itemFromRight--; if(itemFromLeft < itemFromRight) { int temp = arr[itemFromLeft]; arr[itemFromLeft] = arr[itemFromRight]; arr[itemFromRight] = temp; } } int temp = arr[high]; arr[high] = arr[itemFromLeft]; arr[itemFromLeft] = temp; return itemFromLeft; } *Keep in mind that his pseudo code is 100% correct, it just shows a different partition method that can be used to do the same thing. Also I did this rather quickly so if there are any bugs please let me know*
@DeusNudus5 жыл бұрын
its actually not correct, "leftwall = leftwall + 1;" needs to happen right before "swap(array[i], array[leftwall]);" not after it.
@ephy99742 жыл бұрын
Thanks man. I've been wondering why this pseudocode doesn't match the explanation
@jugsma66764 жыл бұрын
Take a pivot as the biggest number, the code will recurse an infinite number of times. And you can't simply swap A[i] and A[leftwall] in for loop based on A[i] < pivot. We also need to consider if A[high] < pivot before swapping.
@winterfoxx63633 жыл бұрын
but how could A[high] be less than pivot if the high is supposed to be a value greater than pivot? and why not always pick a pivot from the middle?
@Versole2 жыл бұрын
Out of all the sorting algrotiems this one the hard to understand but you understand it you'll understand it.
@yazoo0oody93 жыл бұрын
what if i encountered an element equal to the pivot
@sushan_karki5 жыл бұрын
watching this video from NEPAL. Great sir. THANK YOU.
@kylemarcusenriquez47705 жыл бұрын
2:49 I'm assuming you skipped the part where if they were equal you'd continue?
@docteurraton72805 жыл бұрын
You mean itemFromLeft and ItemFromRight? They can't be equal beause they were chosen to be greater and lower than the pivot
@Seanz2088 Жыл бұрын
Thanks for the concise and succinct tutorial.
@Bigleyp3 ай бұрын
Thanks. Pretty simple explanation.
@rajparsi3160 Жыл бұрын
Great tutorial. The sudo code seems to be disconnected with the presentation though. It appears a different way to achieve partition
@MichaelSambol Жыл бұрын
Yeah :/ I didn't put enough emphasis on code early on. Apologies for that. See here for straightforward code: github.com/msambol/youtube/blob/master/sort/quick_sort.py. Let me know if you have questions!