Quick sort in 4 minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 มิ.ย. 2024
  • Step by step instructions showing how to run quick sort.
    Code: github.com/msambol/dsa/blob/m... (different than video, I added this retroactively)
    Sources:
    1. Data Structures and Abstractions with Java by Frank M. Carrano [www.amazon.com/Structures-Abs...]
    2. www.algorithmist.com/index.php...
    LinkedIn: / michael-sambol

ความคิดเห็น • 522

  • @WhisperingWalnuts
    @WhisperingWalnuts 2 ปีที่แล้ว +244

    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

    • @MichaelSambol
      @MichaelSambol  2 ปีที่แล้ว +47

      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!

    • @westsideslasha
      @westsideslasha ปีที่แล้ว +19

      ​@@MichaelSambol I got really confused when the pseudocode didn't match the explanation. You should correct that (in the video) ASAP.

    • @MichaelSambol
      @MichaelSambol  ปีที่แล้ว +52

      @@westsideslasha I'm sorry about that! TH-cam won't let me change the video now unfortunately, but I pinned this comment.

    • @manavshah448
      @manavshah448 ปีที่แล้ว

      I am encountering an infinite loop if I change the while condition to be i < j instead of

    • @amono770
      @amono770 ปีที่แล้ว +4

      i am glad that i looked at the comment section after having a hard time connecting the pesudo code to the video content.

  • @EchoVids2u
    @EchoVids2u 3 ปีที่แล้ว +4357

    With every new quick sort video, I watch, I get more recursively confused.

    • @Iceron55
      @Iceron55 3 ปีที่แล้ว +99

      same lol all the quicksort videos use the same words to explain it

    • @user-wp9pz9hl3z
      @user-wp9pz9hl3z 3 ปีที่แล้ว +24

      hey man, after pulling my hair out for 2 days I finally got it, sadly I had to pay for it.

    • @HACKINGMADEFUN
      @HACKINGMADEFUN 3 ปีที่แล้ว +2

      @@user-wp9pz9hl3z what did u pay for?

    • @user-wp9pz9hl3z
      @user-wp9pz9hl3z 3 ปีที่แล้ว +5

      @@HACKINGMADEFUN a Udemy course

    • @HACKINGMADEFUN
      @HACKINGMADEFUN 3 ปีที่แล้ว +2

      @@user-wp9pz9hl3z cool

  • @jonahrivera7
    @jonahrivera7 3 ปีที่แล้ว +655

    Guy: "I think you understand the concept"
    Me: No I don't

    • @Evokans
      @Evokans 3 ปีที่แล้ว +2

      it gets halved and is recursively applied to both halves in each step

    • @sleevman2307
      @sleevman2307 3 ปีที่แล้ว +1

      @@Evokans um what?

    • @faith2756
      @faith2756 3 ปีที่แล้ว

      @@sleevman2307 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.

    • @sleevman2307
      @sleevman2307 3 ปีที่แล้ว

      @@faith2756 sorry wat?

    • @faith2756
      @faith2756 3 ปีที่แล้ว

      @@sleevman2307 Which part exactly do you not understand?

  • @SAMURAIch
    @SAMURAIch 4 ปีที่แล้ว +434

    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

    • @liuqing1995
      @liuqing1995 3 ปีที่แล้ว +3

      understanding the meaning of pivot is the KEY.

    • @reguret2976
      @reguret2976 ปีที่แล้ว +10

      yeah, theitemfromleft, or right wasn't even properly discussed, left of what or right of what exactly?

    • @skyness9
      @skyness9 2 หลายเดือนก่อน

      lol

  • @alanfender123
    @alanfender123 5 ปีที่แล้ว +1808

    i should be working at mcdonalds

    • @SkillUpMobileGaming
      @SkillUpMobileGaming 4 ปีที่แล้ว +4

      You really should. *SAD!*

    • @IStMl
      @IStMl 4 ปีที่แล้ว +131

      @@SkillUpMobileGaming You too

    • @torment6425
      @torment6425 4 ปีที่แล้ว +1

      wait what. why

    • @asailingstone
      @asailingstone 4 ปีที่แล้ว +6

      lol 😂😂😂

    • @loklyu5691
      @loklyu5691 4 ปีที่แล้ว +3

      that's what I was thinking. you're a genius pal

  • @banderson924
    @banderson924 5 ปีที่แล้ว +1224

    So we let magic handle the rest.

    • @Bridgelessalex
      @Bridgelessalex 5 ปีที่แล้ว +43

      HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA

    • @airex12
      @airex12 5 ปีที่แล้ว +13

      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.

    • @kennethquilantang8080
      @kennethquilantang8080 5 ปีที่แล้ว +1

      @@airex12 so 8 is the new pivot? How can I go through if there is no number in the array greater than 8?

    • @airex12
      @airex12 5 ปีที่แล้ว +11

      @@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.

    • @kennethquilantang8080
      @kennethquilantang8080 5 ปีที่แล้ว

      @@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?

  • @Charoula1608
    @Charoula1608 5 ปีที่แล้ว +576

    *screams in Ross voice* PIVOT! PIVOT! PIVOT!

    • @peizhiyan2916
      @peizhiyan2916 5 ปีที่แล้ว +4

      haha, I can't help imaging Ross's face, hahaha

    • @Daver2212
      @Daver2212 5 ปีที่แล้ว +1

      Me in future, oh Ross's couch sort?

    • @Jiwoo15
      @Jiwoo15 4 ปีที่แล้ว +11

      screams in Chandler voice SHUT UP! SHUT UP! SHUT UP!

    • @mahnazha
      @mahnazha 4 ปีที่แล้ว

      Oh my GOOOOD :-))))))))))))) So truuuuueeeeeee

    • @AbdelhameedG
      @AbdelhameedG 4 ปีที่แล้ว +1

      This is exactly what came into my mind learning about this :))

  • @yufangjuan4994
    @yufangjuan4994 3 ปีที่แล้ว +149

    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.

    • @noahdirksen3623
      @noahdirksen3623 2 ปีที่แล้ว +44

      Thats the fanciest wording I've heard, i would use: "You get it or you dont"

    • @seanzhou2188
      @seanzhou2188 ปีที่แล้ว

      Try to sort a few short sequences yourself according to the steps in the video. You may get the "background knowledge".

  • @sachinpathy6940
    @sachinpathy6940 2 ปีที่แล้ว +5

    i put this at 1.5x and now i learnt quick sort 2.6667 minutes

  • @LL-rn8rn
    @LL-rn8rn 5 ปีที่แล้ว +285

    The psudocode is not intuitively reflecting the walkthrough

    • @diabl2master
      @diabl2master 4 ปีที่แล้ว +3

      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.

    • @jscholex
      @jscholex 4 ปีที่แล้ว +13

      @@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.

    • @diabl2master
      @diabl2master 4 ปีที่แล้ว

      @@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.

    • @jscholex
      @jscholex 4 ปีที่แล้ว

      @@diabl2master Yeah who knows... but I think we can all agree the pseudocode isn't great hah

    • @skarfie123
      @skarfie123 3 ปีที่แล้ว +8

      the pseudocode shows the Lomuto version but the visualisation is for the Hoare version, which is better. See Wikipedia for both.

  • @theducksneezes4987
    @theducksneezes4987 4 ปีที่แล้ว +130

    How to get Confused in 4 minutes
    then again, this was the best video about it so far

    • @4TH4RV
      @4TH4RV 4 ปีที่แล้ว +1

      I want more videos like this where they explain stuff in less than 10 minutes

    • @omegagmysta2092
      @omegagmysta2092 4 ปีที่แล้ว +1

      Bet ? th-cam.com/video/Zh37XyQLHkw/w-d-xo.html

    • @JoelThomas-sr6ti
      @JoelThomas-sr6ti 2 หลายเดือนก่อน

      there's a video by abdul. i think it is best

  • @nabe4320
    @nabe4320 6 ปีที่แล้ว +608

    am still confused

    • @ibu433
      @ibu433 5 ปีที่แล้ว +30

      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

    • @thewiseowl8804
      @thewiseowl8804 4 ปีที่แล้ว +5

      N Betancourt He made it more confusing, for sure.

    • @diabl2master
      @diabl2master 4 ปีที่แล้ว +3

      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.

    • @omegagmysta2092
      @omegagmysta2092 4 ปีที่แล้ว

      Hope this helps :th-cam.com/video/Zh37XyQLHkw/w-d-xo.html

    • @alvin_row
      @alvin_row 3 ปีที่แล้ว +1

      i hope you got it cute bird from nichijou

  • @LGNNorotic
    @LGNNorotic 4 ปีที่แล้ว +93

    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!

  • @mehdibadaoui1658
    @mehdibadaoui1658 4 ปีที่แล้ว +3

    when i search for something on youtube and see one of your videos in the results i genuenly get excited

  • @TheAPlayd
    @TheAPlayd 4 ปีที่แล้ว +1

    That is the exact! same Quick Sort Algorithm we have been thought. Really good! Thanks

  • @MewPurPur
    @MewPurPur 3 ปีที่แล้ว +3

    Yess I finally understood it, having a clear mind the morning before the exam helped

  • @fr5229
    @fr5229 7 ปีที่แล้ว +70

    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.

  • @brianmartinez6193
    @brianmartinez6193 2 ปีที่แล้ว +1

    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.

  • @seltonmc
    @seltonmc 2 ปีที่แล้ว

    Your short videos helped me a looot. Thank you so much!

  • @wendyd.1918
    @wendyd.1918 3 ปีที่แล้ว +42

    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
      @fireboywatergirl1625 6 หลายเดือนก่อน +2

      thats gonna b me td lmao

    • @wendyd.1918
      @wendyd.1918 6 หลายเดือนก่อน

      @@fireboywatergirl1625 i am sure you are at the right place.

  • @dh7222
    @dh7222 7 ปีที่แล้ว +85

    These are some clean tutorials. Thank you for making this!

  • @Kleyguy7
    @Kleyguy7 3 ปีที่แล้ว +11

    I think I'm here for the fourth time now.

  • @davidrichmond9759
    @davidrichmond9759 6 ปีที่แล้ว +2

    These 4 minute videos are great for cramming!

  • @devanshityagi8231
    @devanshityagi8231 5 ปีที่แล้ว +3

    Wow... You just found a place in my mind where you stored quick sort so deeply.🙋💖😂

  • @chinmayhattewar4456
    @chinmayhattewar4456 3 ปีที่แล้ว +34

    Imagine newcomers watching this explanation for the first time.

    • @bethanylowe8773
      @bethanylowe8773 3 ปีที่แล้ว +1

      Thank you. I feel the same about my actual online course I'm studying. And I'm a newcomer. I feel better.

    • @krishnarajj9358
      @krishnarajj9358 3 ปีที่แล้ว +1

      horrible

  • @paulmerg
    @paulmerg 4 ปีที่แล้ว +1

    very well explained and visualised!! thank you!

  • @emilgebl8644
    @emilgebl8644 3 ปีที่แล้ว +67

    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.

    • @christianeichmueller8637
      @christianeichmueller8637 ปีที่แล้ว

      Thanks for the explanation!

    • @jamboy1843
      @jamboy1843 ปีที่แล้ว

      what the hell are you talking about this is a church sir

    • @emilgebl8644
      @emilgebl8644 ปีที่แล้ว +3

      @@jamboy1843 I don't even remember making this comment.

  • @sushan_karki
    @sushan_karki 5 ปีที่แล้ว

    watching this video from NEPAL.
    Great sir. THANK YOU.

  • @alanperaza5696
    @alanperaza5696 4 ปีที่แล้ว +1

    It was quick and I understood everything. Thanks a lot

  • @HelloWorld-tn1tl
    @HelloWorld-tn1tl 3 ปีที่แล้ว +1

    This is the first video that made me really understand how to impl quicksort, and it's very short.

  • @jarencascino7862
    @jarencascino7862 3 ปีที่แล้ว

    This is exactly what I was looking for in a video

  • @M15onehundred
    @M15onehundred 4 ปีที่แล้ว +8

    Nice! Glad to see magic still exists!

  • @nemesis9410
    @nemesis9410 5 ปีที่แล้ว +255

    This is the most confusing and incoherent visualization of quicksort I've ever seen

    • @thewiseowl8804
      @thewiseowl8804 4 ปีที่แล้ว +2

      Well said 👍

    • @ChristianMay21
      @ChristianMay21 4 ปีที่แล้ว +6

      Makes perfect sense to me

    • @thewiseowl8804
      @thewiseowl8804 4 ปีที่แล้ว +2

      Christian May That’s so great! 🙌👏

    • @diabl2master
      @diabl2master 4 ปีที่แล้ว +13

      I thought the visualisation was fine. I feel that I understand it now.

    • @cristian-bull
      @cristian-bull 3 ปีที่แล้ว

      This is the fist visualisation of quick-sort I've ever seen, so I know it doesn't mean much, but I agree.

  • @snake3276120
    @snake3276120 3 ปีที่แล้ว +1

    LOL this is one of the best and easiest video out there on quick sort. All of you disliking it shouldn't do programming.

  • @seanzhou2188
    @seanzhou2188 ปีที่แล้ว

    Thanks for the concise and succinct tutorial.

  • @denisf5664
    @denisf5664 4 ปีที่แล้ว +1

    I have a question: if I skip using a "while" the smaller elements from the beginning than pivot is not more efficient? And I think that because the computer is exempt from doing the first swaps

  • @ragavendhart
    @ragavendhart 5 ปีที่แล้ว +1

    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.

  • @mirana7660
    @mirana7660 2 ปีที่แล้ว

    it's 8:48 AM, i have an exam at 15:30 PM and ur saving me here

  • @Crzynoob
    @Crzynoob 4 ปีที่แล้ว +24

    Psuedo code does not match demonstrated algorithm.

  • @lemonw3906
    @lemonw3906 3 ปีที่แล้ว +19

    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_
      @hiteshsahu_ 2 ปีที่แล้ว +9

      pseudocode is actually wrong as well !

    • @blurryhorizon
      @blurryhorizon 2 ปีที่แล้ว +4

      @@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

    • @Kokil92341
      @Kokil92341 ปีที่แล้ว +3

      @@hiteshsahu_ Exactly , i have wasted so much time over it

    • @scarlettwang2146
      @scarlettwang2146 ปีที่แล้ว

      ​@@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
      @kemot25 11 หลายเดือนก่อน

      @@scarlettwang2146 I think it should be as it is. Something else is wrong.

  • @senaszel
    @senaszel 4 ปีที่แล้ว

    Helped me. Great vid. Fan of your since now. Cheers.

  • @reytampubolon6390
    @reytampubolon6390 2 ปีที่แล้ว

    currently studying for my Algorithms and Data Structure exam, your video is very helpful :)
    thanks

  • @ganimatormusic
    @ganimatormusic ปีที่แล้ว

    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

  • @parthpatel-bt7qw
    @parthpatel-bt7qw 6 ปีที่แล้ว +10

    This was exactly the kind of video I was looking for!! Short and concise, but no loss of information. Thank you.

  • @VictorBanerjeeF
    @VictorBanerjeeF 4 ปีที่แล้ว +1

    Thanks Brother, You save my 10 min exam fast revision time

  • @ZuleyenineIbneNoman
    @ZuleyenineIbneNoman 2 ปีที่แล้ว +1

    You did a great job man! It helps me a lot . Thank you so much.

  • @SuperJosba
    @SuperJosba 2 ปีที่แล้ว

    Perfect explanation of quick sort!!

  • @haloum
    @haloum ปีที่แล้ว

    this made it a lot more logical for me, thank you.

  • @Agman3a
    @Agman3a 2 ปีที่แล้ว +1

    Thank you so much! I was having so much trouble understanding this algorithm but you saved me in 4 minutes.

  • @yessirski7868
    @yessirski7868 2 หลายเดือนก่อน

    people are complaining but this is gonna come in clutch for my wirtten exam tmr.

  • @georgygursky4303
    @georgygursky4303 4 ปีที่แล้ว

    This is a good explanation, thanks !

  • @LR-ke5pw
    @LR-ke5pw 3 ปีที่แล้ว

    I actually understand a little bit now, thanks!

  • @Shivam25Verma
    @Shivam25Verma 2 ปีที่แล้ว +1

    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.

  • @lil-mi-777
    @lil-mi-777 2 ปีที่แล้ว

    The video hold the key of quicksort, most clear to me!

  • @swetashinde1184
    @swetashinde1184 6 ปีที่แล้ว

    Great videos I like your work :) It is very easy and quick .. All the best for future videos and work

  • @mekabare
    @mekabare 4 หลายเดือนก่อน +1

    I'm seeing myself working customer service for the rest of my life

  • @bohdankholmaniuk8023
    @bohdankholmaniuk8023 5 ปีที่แล้ว

    Thanks, it really helped.

  • @akira_asahi
    @akira_asahi ปีที่แล้ว

    Thank you for the video. I am grateful for your time and contribution. Kind regards, Akira.

  • @yahiashams2334
    @yahiashams2334 2 ปีที่แล้ว

    That without voice over made the video from great to perfect

  • @JA-vt1mh
    @JA-vt1mh 3 ปีที่แล้ว

    this is a very clear explanation, thanks

  • @noddycode7324
    @noddycode7324 5 ปีที่แล้ว +2

    QuickSort has always been a bit of a mystery to me, but somehow this video instantly made it click. Thank you so much!

  • @ToriliaShine
    @ToriliaShine 2 ปีที่แล้ว

    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 ;-;

  • @godaimer999
    @godaimer999 2 ปีที่แล้ว

    explained it much fckin better in 4 minutes with 1.5x watchspeed than my teacher in a 90 minutes class, thank you sm

  • @joshuabrown604
    @joshuabrown604 2 ปีที่แล้ว +6

    Thank you so much! Just understood how to do a quick sort in a few minutes. Fantastic Video! Keep up the great work 😀

  • @cb350_
    @cb350_ 4 ปีที่แล้ว

    Thank you finally understood quicksort
    😌😌

  • @arminkrahbar
    @arminkrahbar 2 ปีที่แล้ว

    The visualization is perfect!

  • @IOSALive
    @IOSALive 2 หลายเดือนก่อน +1

    Michael Sambol, You're amazing! Let's be friends and have fun together!

  • @jeffchai6561
    @jeffchai6561 3 ปีที่แล้ว

    This algo is akin to a toddler randomly sorting numbers around until they're in order

  • @MoguMogu818
    @MoguMogu818 4 หลายเดือนก่อน

    I was able to write quick sort in a day when I first learned it, and now I completely forgot and feel stupid. This is my major, how tf did I forget this algorithm.

  • @alish2001
    @alish2001 ปีที่แล้ว

    solid video mate

  • @user-fc5ou7pn2k
    @user-fc5ou7pn2k 2 ปีที่แล้ว

    amazing, ive got an exam tmrw... this lesson is much appriciated as my professor is not very good at explaining these basics

  • @williamgreen9280
    @williamgreen9280 ปีที่แล้ว

    Excellent explanation

  • @pebble2258
    @pebble2258 3 ปีที่แล้ว +3

    The comments on this video do not reflect the like/dislike ratio.

  • @walteramenya5759
    @walteramenya5759 6 ปีที่แล้ว +35

    here for the comments

  • @SooDiStUrB3d
    @SooDiStUrB3d 4 ปีที่แล้ว

    Great explanation, thancc lots!

  • @dularamalindu427
    @dularamalindu427 4 ปีที่แล้ว

    Thank you. Vell explained. and easy to understand

  • @bryanbocao4906
    @bryanbocao4906 6 ปีที่แล้ว

    Great tutorial! Actually I understood this concept from this video in less than 4 mins.

  • @olivercrawford8512
    @olivercrawford8512 2 ปีที่แล้ว

    Brilliant video mate!

  • @redofficiale
    @redofficiale 2 ปีที่แล้ว

    Thanks. Great video

  • @thuynh2608
    @thuynh2608 2 ปีที่แล้ว

    I am glad I read the comment to know that I am not the only one!

  • @nolanrudolph5463
    @nolanrudolph5463 5 ปีที่แล้ว +1

    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

  • @farlandduck4463
    @farlandduck4463 5 ปีที่แล้ว

    makes sense to me. Thanks!

  • @Socrates225
    @Socrates225 3 ปีที่แล้ว

    brilliant explanation

  • @walkieer
    @walkieer 5 ปีที่แล้ว

    This guy is amazing.

  • @J4T375
    @J4T375 3 ปีที่แล้ว +2

    all your videos are short and very useful.

  • @praneethaluru2601
    @praneethaluru2601 7 ปีที่แล้ว +2

    THAnk you very much..

  • @smbowner
    @smbowner 3 หลายเดือนก่อน

    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!

  • @LexStilinski
    @LexStilinski 2 หลายเดือนก่อน

    Him: “quick sort = pivot”
    Me: “WHILE HE HID IN RADIO WE PIVOTED TO VIDEO 🗣️💥”

  • @DT-ll8og
    @DT-ll8og 2 ปีที่แล้ว

    Thanks for clear explanation. Correct Position for Pivot, let recursive do remains. Good job man.

  • @grevierx
    @grevierx 2 ปีที่แล้ว

    How do you find the median of three "middle" value on an even number of elements in a list?

  • @karaqore
    @karaqore 2 ปีที่แล้ว

    Hvala ti brate pomogao si mi puno u životu

  • @dannylones2159
    @dannylones2159 3 ปีที่แล้ว +1

    saying "move pivot" but instead swapping it with last number 🗿👍🏻

  • @Athanas007
    @Athanas007 4 ปีที่แล้ว +1

    0:10 who else thought of Ross screaming Pivot from that Friends Episode

  • @user-cm5dl6lp5o
    @user-cm5dl6lp5o 4 ปีที่แล้ว +1

    that was quick, indeed

  • @miso-ge1gz
    @miso-ge1gz 8 หลายเดือนก่อน

    i cannot even describe how much i hate learning these, thanks for the video it helps a lot

  • @goyo9198
    @goyo9198 ปีที่แล้ว

    How do you pick the item from left, based on what? I know it has to be larger but in the video you chose 6, wouldn’t 5 also work?

  • @mixitup92
    @mixitup92 3 ปีที่แล้ว

    bro thanks for this kick-ass video

  • @kellypeng6371
    @kellypeng6371 5 ปีที่แล้ว

    Thank you dude you save me from the finals.....

  • @vinjetho1609
    @vinjetho1609 6 หลายเดือนก่อน

    dont know if people will still answer questions on this video, but i tried implenting this, but i have a problem with when there's two or more copies of the smallest value it gets stuck because it tries ti continue until the index of item from right is at the end of the list, but since there are multiple of the same values at the end of the list, index of item from right doesnt continue to decrease.
    Basically: how do i check that it has completed one pass and the smallest/largest item is at the end?

  • @Rglezy
    @Rglezy 3 ปีที่แล้ว

    FINALY SOMEONE WITH CLEAR INSTRUCTIONS