Sorts 8 Quick Sort

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ธ.ค. 2024

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

  • @LeoUfimtsev
    @LeoUfimtsev 6 ปีที่แล้ว +243

    I've watched about 6 videos on Quicksort. This one is really the best because it first explains the theory and then the in-place algorithm, where as most other videos only explain one or the other but algorithm is confusing if you don't understand the theory behind it. Thank you for this post.
    The reversed on-glass writing is kinda cool as well. Kudos.

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

      agreed!!! holy god this is mind blowin. great work sir!!

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

      Did you really believe that he was writing inverse?
      And His left-hand writing is just coincidense then? Don't be naive! The video is mirrored obviously!

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

      Can you please help me with Sorting a Singly Linked List using Quick Sort. Please whatapp me if you can help me +919041121318 or mail me at mann.ramin@gmail.com. Thanks In advance..

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

      exactly!!

  • @benid3163
    @benid3163 6 ปีที่แล้ว +56

    Wow. This should be the #1 search result for quicksort in TH-cam. Understood it, and am now going to code it!

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

      Beni D agree, all others are very confusing.

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

    I have been through video after video, website after website and NONE of them were able to help me understand quicksort. Within the first 2 minutes of this video it all made sense. THANK YOU!!!

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

    Bro you are the best ! Man literally watched 7 videos to understand this method but your video is the one to understand this method

  • @piyushsharma1638
    @piyushsharma1638 6 ปีที่แล้ว +70

    teaching style is awesome.

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

    The only Quicksort vid that was Quick to understand ❤️

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

    I feel like I watched 10 other videos and read a few articles about this but this finally got it through my head properly. This is really something that needs to be explained just like this to understand. I was getting far to bogged down with the recursion element to fully grasp the simplicity of this algorithm. This is a great explanation because it really just boils it down to what is actually happening, and the logic. Rather than getting encumbered by the actual implementation in a particular language.

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

    Am I the only one who is impressed not only with his algorithmic interpretation, but also with his digital whiteboard

    • @oo-gr2sw
      @oo-gr2sw 2 ปีที่แล้ว +1

      I think he uses translucent/noctilucent board markers.

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

    One of the best explanations of Quick Sort. Thank you !

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

    Clear. Concise. To the point. Will take a few watches but it was so clear and made so much more sense than what was taught in my algorithms class at school , lol.

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

    Amazingly done... my own lecturer left me more confused than before when he spoke about it

  • @Nikki-vg2pu
    @Nikki-vg2pu 6 ปีที่แล้ว +9

    Best explanation I've found so far!

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

    These videos have helped me through my data structures courses IMMENSELY.

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

    Best explanation on TH-cam. Thanks for this amazing content.

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

    This was the best way to learn it, I'm Mexican and my teacher is so bad, thanks to you teacher Rob

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

    I finally understood after watching this and was able to implement the algorithm. Thank You!

  • @imlijunglalongchar1858
    @imlijunglalongchar1858 5 ปีที่แล้ว +114

    I just spend the first 2 mins trying to figure out how they filmed it XD

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

      probaly a transparent wall and mirorred video by edit

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

      it's called learning glass, it reverses the image in real time. No editing whatsoever

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

      @@manuelfideles9468 no, the learning glass aka Lightboard does not reverse the image in real time. "...The lecturer writes on
      the glass surface with fluorescent markers while the session is recorded...Because any written text will be backward in the direct camera view, the text orientation must be flipped, either by pointing the camera toward a mirror reflecting the Lightboard and the presenter or by digitally reversing the image..."

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

      First time I was same )

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

      Glass wall and video mirroring
      Edit: spelling

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

    Wow. Best Quick sort explanation. Deserves more views

  • @Farrukhw
    @Farrukhw 6 ปีที่แล้ว +1

    Thanks a lot Rob for all your hard work and making it easy to understand... Really appreciated ... :)

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

    thank you, this is the best quick sort i have seen, thanks.

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

    Best explanation of quicksort I have found so far

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

    8:50 yes, but if the list is sorted, then the middle is better.

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

    Thanks Dr.Edward This video is really clear. I had a hard time in class to understand this.

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

    This is the best explanation I have seen so far.

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

    Thank you, been trying to understand this for 4 videos including my instructor. Good Job.

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

      All the videos are different. Wtf? Now what?

  • @Revelatus
    @Revelatus 6 ปีที่แล้ว +259

    swop

    • @FredoCorleone
      @FredoCorleone 5 ปีที่แล้ว +7

      It seems correct even though it sounds weird

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

      Its an optimized version of swap. Performs at least 10 times faster

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

      He is British.

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

      I was like "why is he making fun of how he says swap" and then it hit 6:29 and I understood what you were referring to XD

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

    I'm Studying here in Sandiego SouthWestern College, Dr. Edwards you inspire me to transfer over SDSU to finish my Computer Science degree

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

    This should be at the top of the search list.

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

    Your teaching method is really cool, and makes the viewer really comfortable. It's amazing how you write inverted symbols on your side :-D

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

    This guy is creepily good at writing backwards...

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

      I hope you're kidding. lol

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

      @@jrhager84 No? Am I missing something?

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

      Oh, did they just mirror the video?

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

      @@tsukikage bingo

  • @ibtisam-z9
    @ibtisam-z9 5 ปีที่แล้ว +2

    You're brilliant! Best explanation so far.

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

    Best explanation of quick sort I have found! Thank you.

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

    This is the best video on quick sort!

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

    Thank you so much for your videos. You have a talent to explain things in easy way!

  • @SageofToads
    @SageofToads 6 ปีที่แล้ว +1

    Best quicksort video ive seen.

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

    Thank you professor!! This is really clear and understandable, I now understand how partition work and how it works with pivot point.

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

    THE BEST EXPLICATION FOR QUICKSORT!! THANKS

  • @christopherward7232
    @christopherward7232 6 ปีที่แล้ว +1

    This was a great video! Actually managed to follow through your method and stopping to code each step that you explained. Thanks :)

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

    3:41 wouldn't you have to quicksort one more time since it's not guaranteed at that point that the remaining list is sorted? The list could still be [12, 11] instead of [12, 14] at that point.

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

      That's the only problem in quick sorting, but it happens rarely that's why quick sort is being used mostly

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

      Kurt Weyne Gaso don’t think that’s a problem with the algorithm itself they just forget the last iteration

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

      @@RickAstley1988 i don't think people use "sorting algorithms" with small chances to just return unsorted data..

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

    Excellent method of teaching. Every one can easily understand

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

    You can tell dropping that lid really bugged him

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

    4:08 if the numbers are randomly sorted then, any number in the list has the same probability of being in the middle of the sorted list... so you could just pick the number of the very right no? Edited: 8:38 lol he answered my question by the end of the video :)

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

    Thanks.
    Notes: Partition algorithm at around 5:00

  • @MegaRc1989
    @MegaRc1989 6 ปีที่แล้ว +82

    how are you writing backwards!?

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

      He's writing on a glass.

    • @phillippebr
      @phillippebr 6 ปีที่แล้ว +25

      They are filming a mirror. He is writing normally in a glass (so everything is backward) and they are filming a mirror pointed to it (making it forward again).

    • @hussainm8407
      @hussainm8407 6 ปีที่แล้ว +61

      or theyre just flipping the video in post

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

      @@hussainm8407 BAHAHA xD

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

      sorcery

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

    Using the last element as a pivot is necessarily not a good option if there is even a slight chance that the list could be (nearly) sorted. A good option for pivot selection is the median-of-three method in which you choose the median of the first, middle and last element of the list as your pivot. This leads to efficient behaviour for all inputs.

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

    I don't understand 5:18. what if it wasn't a 10 but a 1? where would you swap that to?

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

    How can we exactly count the number of comparisons? I establish a counter for 10000 number am I obtain 9999. If I consider the recursion -1 each time the numbers goes to 12K. Depending of the start or end or media election differs too.

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

    This guy is awesome, I'm learning sorting algorithms thanks to him. One day baby I'll be sorting integers at Microsoft!
    _function quickSort(array) {_
    _if (array.length

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

      In practice, the number of times you ever need to sort a list of pure numbers is small. It's far more common that you need to sort some structured data, where there's some item within the structure that is the sort key. When I started programming 40 years ago, it was reasonably common to hand code a sorting algorithm for some application, now every modern language comes with a Quick sort algorithm that you no longer need to worry about. How it works is of purely academic rather than practical interest.

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

    Well done and nice job with the reverse writing. That made the video really viewer friendly.

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

    Great video. I was a bit skeptical when you mentioned your reasoning to pick the mid point as the first pivot in a randomly sorted list, but at the end it was a misdirection. The only thing I would add is maybe a bit of pseudo-code, since it might be better to demonstrate the recursiveness.

    • @Brandon-oo1qi
      @Brandon-oo1qi 4 ปีที่แล้ว

      Why would you be skeptical of choosing the middle as the pivot? That's literally the best possible outcome, lol! Unless your goal is worst case O(n^2) you should always choose the middle unless you know something about the list (as in some special case where it's always x).

  • @omarabdelkader5214
    @omarabdelkader5214 11 หลายเดือนก่อน

    Thank u for ur great explanation, got it from the very first time

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

    Best video...... finally understood the concept... thanks sir

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

    best explanation I saw so far

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

    Awesome!
    Very short and to the point.

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

    So the swapping of 6 and 8 is not required. Just use the last element in the list. I think this is the inplace quick sort using Lomuto partition schema.

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

    really great work . It felt like listening to the John Danaher of sorting xD

  • @JoffreyB
    @JoffreyB 6 ปีที่แล้ว +5

    but what about array of |8|10|7|12| , out pivot is |12|, i and j counters in this case will go together until the end, coz all elements are smaller than pivot. And in the end we should switch |7| with |12|, isn't it? but we will get then |8|10|12|7| , which is far from true. Somebody explain me please this moment

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

      Watch the vid agin .we skip through the i(update it by 1) when element(i)>pivot.so swaps take place before pivot and element(j )swap.

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

      Actually in that case counter who is remembering current posn will remain at 8 and other counter which is finding 1st element greater than 12 will iterate and end the array nothing will happen. And in next step you will send arr 8 10 7 in recursion and 12 in recursion

    • @911wildman911
      @911wildman911 6 ปีที่แล้ว

      I believe I've found an answer here, having encountered the same confusion when reviewing this myself. When you have this scenario, you simply do not perform a swap at the end. The final value before the pivot value is considered to be in its "sorted" position. From there you can mark the final value sorted and continue the process with a new pivot.

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

    I would give 10 likes if I can for this video!
    Very well explained! Thank you!

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

    Thank you for this wonderful explanation!

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

    First value is taken j last value is pivot is taken if first value j is less then pivot what we do and i is taking increment to the j

  • @KA-jb4qv
    @KA-jb4qv 4 ปีที่แล้ว

    how come the video was captured?.. he seemed writing in air, and he is facing opposite to us

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

    i can't get, what is the second part about?

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

    Describe precisely the pivot step of QuickSort, using the median-of-three method for
    pivot selection, and show every stage of the rst pivot step applied to the array with the
    following entries:
    3; 4; 7; 1; 2; 6; 5

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

    Quite unruffled after the pen lid dropped. Very cool

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

    What sorcery is this

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

    is he implying that the middle number of an unsorted list is better than any other as a pivot choice as it is likely to be nearer the median than the others?

  • @AmnaTahir-h4h
    @AmnaTahir-h4h 11 หลายเดือนก่อน

    SUPER HELPFUL!!! THANK YOU SO MUCH

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

    Very good explanation! Thank you very much :D

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

    The comments here:
    🤯 I was much more amazed by how he was able to disappear and then reappear in almost the same place!
    Then I realised, this must be what recursion is...
    I am learning!

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

    Thankyou! you made this concept easy to grasp

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

    Thank you! Its a great mini lecture)

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

    I still don't understand why choose the middle number as pivot point and then swap it with the end number in the almost sort list? Am I miss something?

    • @icosmini
      @icosmini 6 ปีที่แล้ว +1

      That is confusing, he shouldn't have said that. You actually simply choose the last number as pivot. And you do that so that you can freely move all the other numbers around.
      And then at the very end, when you have the set of small numbers and the set of large numbers, you put the pivot between the two sets.

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

      @@icosmini it is not confusing actually you can chose any number as a pivot, then have to swap it with the last one ,, choosing last one as a pivot is convenient . pivot means here that you have to place this element at its right place and left elements must be smaller and right must be bigger

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

      right place means where it should be .

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

      that will help alot if you sorting nearly sorted set where there will be less swaps mostly if you use the mid number

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

      middle is for the meaning, the last is for the implementation

  • @911wildman911
    @911wildman911 6 ปีที่แล้ว

    Something does not appear to be correct here or maybe I am misunderstanding. With the 8, 10, 7, 12 sort you would do if you had continued this example, all the elements are less than the pivot (12). Your blue/orange counters would stay together until the end, resulting in a swap of 7 and 12, resulting in 8, 10, 12, 7. This is not correct. Is there some gotcha or small detail here that I am missing in which the result would come out correct? Thanks!

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

      >resulting in a swap of 7 and 12
      You would end up with swapping (12 with 12) nothing BUT! You would have a new pivot winch is 3(12). End the next iteration would be:
      leftSort(0, 3 - 1),
      rightSort(3 + 1, 3)

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

    Great explaination and u r sophisticated person

  • @jorgericaldi6438
    @jorgericaldi6438 7 ปีที่แล้ว

    Greetings from Peru. Awesome videos!

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

    great video but the list is not sorted lol 9:00

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

    Thanks a lot!
    Also for no annoying music!

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

    am too lazy in writing a comment but this tutorial made me do that! THANKSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

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

    The partitioning algorithm is not optimal. If an array is in descending order the swap would do unnecessary job.

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

    Geniusz dydaktyczny. Brawo.

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

    Excellent explanation.

  • @chigoziea.991
    @chigoziea.991 6 ปีที่แล้ว

    I do have to say this algorithm is just slightly different than some other youtube videos :P. Great video!

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

    Thanks, this made it so clear.

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

    beautiful explanation!

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

    Excellent explanation

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

    best quick sort thanks

  • @ИльяЛагойда
    @ИльяЛагойда 7 ปีที่แล้ว

    Very good lessons. Thank you!!!

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

    Superb explanation 🙏🙏

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

    Thank you sir
    Great work😊

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

    Very helpful, thank you! :)

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

    Seems a lot easier to just do a normal sort smallest to largest. Don't understand the reason for the complexity.

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

    great sir!! KEEP IT UP!

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

    BEST OF THE BEST !

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

    Best explanation

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

    Thank you!

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

    THANK YOU SIR

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

    The sound made between the pen and the glass...

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

    THANK YOU

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

    'crystal' clear.

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

    good one. thanks a lot