The Quicksort Sorting Algorithm: Pick A Pivot, Partition, & Recurse

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

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

  • @nano959
    @nano959 5 ปีที่แล้ว +389

    A CS tutor that speaks clearly and concisely??? Very rare!

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

      yeah

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

      Jonathan Banuelos you mean he doesn’t speak Indian accent lol

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

      @@alanliang9538 what do you mean by that??

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

      @@pulkitjain8135 racism

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

      just say you're xenophobic and move on

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

    FINALLY someone who explains what a pivot is. Pivot concept is key to understand how quicksort works and also to understand "the kth largest element in an array" problem.

  • @brett9769
    @brett9769 5 ปีที่แล้ว +97

    Hey man. Been watching your videos for a few weeks. Your explanations and thought process is exactly what I needed to get a refresher on all things ds&a. I just recently landed a job offer at a dream company, so thanks a ton for all your hard work and help!

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

      nice. Hope work goes well and you are happy :)

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

      My feeling is also same here, Iwas searching for this kind of thinking ability

  • @BackToBackSWE
    @BackToBackSWE  5 ปีที่แล้ว +57

    Table of Contents:
    Talking About Stuff 0:00 - 1:05
    Introducing Quicksort 1:05 - 2:04
    The Split Subroutine 2:04 - 2:43
    The Partition Subroutine 2:43 - 3:24
    Partitioning: Choosing A Bad Pivot 3:24 - 10:34
    Partitioning: Choosing A Good Pivot 10:34 - 15:11
    Analysis: Choosing Bad Pivots 15:11 - 19:06
    Analysis: Choosing Good Pivots 19:06 - 22:07
    Analysis: Good Pivots - Work Done At Leaf Level 22:07 - 23:37
    Flashback To Merge Sort 23:37 - 24:01
    Why Quicksort Is O(n*log(n)) 24:01 - 25:02
    Wrap Up 25:02 - 26:12
    Errors:
    3:25 - 15:11 -> I messed up how I advanced 'i' in both examples. I should have started 'i' at left - 1 everytime...my bad. What should happen is that we should start 'i' at 'left - 1' and anytime we swap into 'i' we always advance 'i' FIRST before the swap. These errors don't change the fundamental job of 'i', which is to keep the tail of the section of items less than the pivot. Make sure you take that away from this.
    4:02 -> Forgot to edit that text out haha
    24:23 -> This is only the exact bound on the best case. Not the average case as well.
    The code for quicksort is in the description. Fully commented for teaching purposes.

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

    2022 and you're still helping people. I'm not enjoying my classes but watching your videos give me reassurance that I really like these topics. Thanks a lot man!

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

      Glad to hear that! Subscribe to our DSA course with a flat 30% discount for some amazing content b2bswe.co/3HhvIlV

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

    This guy's : is this ever impacting u?
    Me : what? It's saving my life

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

    You're one of the most eloquent tech guys on youtube. I just started programming this month, and your video helped me implement quicksort in JS!

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

      great! but im not a tech guy, Im just a guy

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

    Dude. Thank you for putting the time in making these videos. They are IMMENSELY helpful! Don't burn out making them, take your time, do them at your pace, cause they are some of the best in the business. Really, you are awesome.

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

      Thanks. I haven't burnt out. I just started work in San Francisco and I am building a pretty cool and fancy site for this channel which I hope to launch mid-end of July. Once it is out I'll be back on the throttle to post more technical videos as I support the site and begin working on the next software.

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

    Stumbled upon this during my interm. algorithms class at UC Riverside. Honestly dude, your short videos do more than entire lectures for my understanding. Thank you.

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

    One of the best Tech -tuber, has an website on interview prep and still gives his best in youtube explanantions and dont advertise his website on youtube like tech lead , clement does,
    tech-lead and clement should learn from him on how to give best in youtube and stop honeytrapping vulnerable kids

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

      thx

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

      tech lead is a psychopath lol

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

    It's impacting. In a good way. Most professors in most cs programs really don't go into detail about these algorithms much. Even grad school programs have that problem at times because then it seems like you should know these things. You're doing a good job and hopefully this channel and others stick around.

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

    Don't stop doing what you're doing! These videos have been an incredible help in getting my head around algorithmic time complexity for my computer science masters - thank you!!

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

    now we are at 161k
    thank you for all your efforts
    love from india

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

    This is one of the Back to Back SWE videos have helped me understand "Introductions to Algorithms" - a book probably aimed at people who already understand the algorithms in question. I am so glad for this series. Thanks a lot!

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

    you have been a huge factor in helping me understand some of these concepts. Please keep it up. You're the first place that I go when I'm having trouble.Thank you!

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

      Thank you, glad you liked it 😀
      Do check out backtobackswe.com/platform/content
      and please recommend us to your family and friends 😀

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

    One of the best instructors on TH-cam! Thank you for your contribution!

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

    Impact ?? it's life saver.... when ever i get stuck on some basic concepts ..this is the place i jump to... keep up the good work.

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

      hahaha thanks, yeah I'm back, about to make a ton of videos

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

    This guy is a genius, find an easy and intuitive way to explain.

  • @carson6954
    @carson6954 5 ปีที่แล้ว +66

    I wish I just watched your videos instead of taking my algorithms and data structures class

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

    dude you're literally the only reason why I understand these algorithms. My CS 101 prof teaches so weirdly, you should really consider pursuing academia if you haven't already

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

      thanks and I do not want to

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

      @@BackToBackSWE relatable LOL

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

      @@BackToBackSWE lmao

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

    "We do not place an item, into the section, that is less than the pivot." - just needed that much.
    Thank You, Brother! #keepUptheGoodWork.

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

    You are my favorite! What is really helpful is that you explain the idea, which is what a lot of videos don't do. Mosts just focus on the coding, but not in the concepts. I'm very thankful I found you!

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

    This is the only vedio I found which tells exactly what exactly is PIVOT.. THANKS
    BRO

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

    Thank you for making these videos! The way you explain and break down things are great! They are helping me so much here in 2022 and I am going to try and watch all of them. I wish you much success in your career!

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

      Thank You!!
      Do check out backtobackswe.com/platform/content
      and please recommend us to your family and friends :)

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

    Hey man thanks for posting these videos they are helping me a bunch, I'm about a month out from my job hunt, using your videos to prep while I continue to learn some Angular. Going to pitch in what I can for the Patreon thanks again !!!

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

      Aw, thanks

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

      Hey Man i am also in the same position with Algo and Angular but i think i am comfortable with Angular, Do you want to study together ?

  • @KanonetTI
    @KanonetTI 8 หลายเดือนก่อน

    For sure your videos is causing a positive impact. At least, for me this channel is so valuable. Great job man!

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

    Hey, my friend. I'm an SDE with a couple of years of industry and academic background. I really appreciate your effort to explain this algorithm. Regardless of the commercial purpose behind the video, your explanation is mostly accurate and easy to understand ( Though I have to say, it's better for you to put the average case before the worst-case example in this video.) Carry on, looking forward to new content from you!
    btw: I have the confidence to say many, yes many, explanations of quicksort from some others are WRONG. Well done, sir!

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

      one more suggestion, I will be better for you to explain why quick sort is "Quick". I know the answer..but..I'll leave the work to you...

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

    Watching from Chicago and love this so much! Thanks for clarifying this algorithm.

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

    I've never understood something so clear... thank you so much! :')

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

    I guess you have not enough subscribers and watches! One of the best CS videos I ever seen. Thank you!

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

    Thank you so much,you probably dont know how much this means to me. Love from india🇮🇳

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

    I haven't understood quicksort for 2 years, thanks a bunch man

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

    probably the most easy to understand video on quicksort. Thank you

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

    You're very good at explaining. I watch your videos and they make me very happy

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

    Hay man I just want to say thanks for all the videos because of that today I am having f2f interview in Amsterdam. I am not sure I will pass or not but you gave me enough confidence to face it.. :) cheers

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

      Hahaha nice! I just came back from Amsterdam...like 2 days ago. That's wild. I walked past the Oracle office behind this one Dutch dude who was speaking Dutch and he had a cool Oracle bookbag.
      Ahhh...good times.

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

      @@BackToBackSWE Ohh I missed my chance of doing mock interview with you :p

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

      @@jageenshukla4825 haha

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

    Hey Bro.... Just wanna say... Keep up with your videos, they help students like us all around the globe..... ❤️❤️❤️❤️❤️❤️

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

    What a great teacher, my god! always amazed by your skills ❤

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

    Wonderful tutor! With each passing days, I am falling in love with Algo's, good job brother..looking forward to have more lessons from u.

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

    I hope you realize that you are changing peoples lives!(for the better).

  • @AvinashKumar-pl7wc
    @AvinashKumar-pl7wc 5 ปีที่แล้ว +2

    I wish i could like the video million times. Thanks for the gift.

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

    why is this guy better than the lecturer in my course that I paid $2.2k for?

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

    At 10:38, you say that it doesn't matter where i starts; as far as I saw the algorithm says it's got to start at start - 1, which de facto makes all the passes in the first iteration to swap i with j, but all instances of i and j are equal (that's cause you increment the i before the swap), or the condition about array[j]

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

    You are a legend. I always go watch you on here before a class :)

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

    ı hated data structures lectures before thıs man but now I can easily understand everythıng .thank u a lot .You are my hero :)

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

      Happy Holidays 🎉 this means so much, thanks, songulmesale! We'd love to offer you a 40% Off our exclusive lifetime membership just use the code CHEER40 - backtobackswe.com/checkout?plan=lifetime-legacy&discount_code=CHEER40

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

    give this man a gold metal! respect!

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

    this channel deserves more than million subs

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

    I have never commented on a TH-cam video before but thank you so much for this! Your code for Quicksort actually makes sense, which is something I have not found to be the case for other sources, including Cracking the Coding Interview. I have subscribed :)

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

    The example at 11:00 can be more helpful if it has a number in the first half that is greater than the pivot, for example [3, 8, 4, 5, 9, 7] and pivot is 7. when i = 0, j = 1, we don't do the swap since 8>7, then j becomes 2 and based on your description we swap 3 and 4? What about 8 in between them? It should not stay where it is

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

    Amazing Videos ! I love how you explain everything at the deepest level which is exactly what I need to understand those algorithms properly :D

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

    TY so much. Clearest quicksort video on youtube

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

    Teaching is an art and you are an artist :)

  • @Victor-cg4hx
    @Victor-cg4hx 2 ปีที่แล้ว

    It's glad to see that my favorite basketball player Chris Paul teaching the algorithm courses.

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

    Your videos are really awesome and have helped me alot in my data structures class for LSU. Thank You!

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

    Thanks for hard work, I can see how much effort you put in this video.

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

    Amazing videos, the only teacher who actually explains algorithms clearly! One question- at 11:19 you said that "it does matter where i goes... I messed up... but you get the idea". Where should i go, at -1 or 0?

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

      I saw in your attached code that i starts at -1, so that when j finds a number, i will be incremented to point to the next available spot in the 'less-than' portion. Then the swap occurs, and j is advanced forward. However, I've also been messing around with my own implementation and it seems that you can start i at 0, as long as you perform the swap first and THEN increment i. When it comes to reinserting the pivot, it needs to be at i (rather than at i+1 when i starts at -1).

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

    The best explanation ever, so detailed, I really enjoyed it!

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

      nice

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

      Sir, I really need a help from you, I am not really good at Dynamic programming and there's a problem that's eating my head for a long time, could you please please please solve it and make me understand?

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

      The problem is "Faffa and The Ancient Mathematician" from Code forces.

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

      There an explanation of the problem by Rachit Jain on TH-cam but I didn't get the multiple DP going on in parallel. Please help me, coz there's none to guide me! Thanks! :)

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

      @@vibekdutta6539 haha um, I'm pretty busy, I'd love to but don't think I can make the time today

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

    Best content I have ever encountered

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

      thx

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

      @@BackToBackSWE you really read your comments. Only some have this quality.
      Really Impressed

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

      @@saurabhjindal2775 Yeah haha, why wouldn't I. I really care about what I'm building.

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

    Perfect! I really love that, you explain it as good as it's posssible. Nice.

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

    You explanation is amazing. be assured that one day I will take few days off to watch all your algorithm themed videos :)

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

    I like your videos even before starting .. that's how much I like your content..keep making this kind of videos pls :)

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

    This channel made me love algorithms again

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

    at 2:13 what are the inputs? A is the data array, l is what, and r is what? is this executed in a loop?

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

      I dont rememebr the code

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

      Back To Back SWE what about the concept of what l and r are

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

    It is really much helpful and good then our professor lectures

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

    You had a great impact on me!!! You are a blessing!!!!

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

    Finally understand quick sort! Thanks so much

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

    If i could like this 100 times i would 😩omg best video on youtube about quicksort! I literally have watched all lol thank you for making these videos

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

    You are gifted! Thanks for making these concepts easy

  • @joy-sm5sl
    @joy-sm5sl 3 ปีที่แล้ว +1

    2021 and your explanations still helps, a lot. thank you so much! gonna binge on your vids and hopefully it helps my journey throughout this CS major :')

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

    Thanks for this, I was actually wondering couple days ago why there isn't a sorting video for quick sort.

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

      yeah, give me a year or 2, this channel needs to be fleshed out more. I'm aware of all that's missing for the most part.

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

    Hello. I have a question. Im 10:25 and i dont understand why the complexity in this case is 0(n^2) . It should not be n! ? Because there are n-1 steps , n-2 steps , n-3 ... 1 ?

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

      Was this for worst case?

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

      @@BackToBackSWE yes . But i continued to watch this and i understood.

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

      Because there are n + (n-1)+...+1 and this is the gauss sum

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

    Continue! You are doing great, man! Thanks a lot!

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

    YOU ARE HAVING AN IMMENSE IMPACT. AND THANKS FOR IT!!!

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

    Does anyone understand how 17:32 worked? I would have thought the summation would be the sum n-i from i=1 to n-1. This is due to the pattern of seeing n-1, n-2 , n-3 on each level and needing to add them all together

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

      This seems to be a mistake but I don't remember the math from this video too much. I was going straight from notes I took before the video so not sure what I was on about. It still would be quadratic comparisons: imgur.com/a/MWQOBkd. Can you affirm this was a mistake? Then I can update the pinned note to point it out. Thanks!

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

      @@BackToBackSWE No problem at all, so sorry for the late response was so deep into algos study that I never looked at TH-cam until I finished my exam yesterday! The maths checks out. If you think about it the sum of (n-i) for i incrementing all the way to n does just equal the sum of i. For instance, let n be 5 and i = 0 and lets follow the (n - i = val) format. (5 - 0 = 5) + (5 - 1 = 4) + ... + (5 - 4 = 1) Which is the same as 0 + 1 + ... + 5. I hope that cleared that up, thanks for making this content, I absolutely love your videos and will continue to subscribe even beyond algos class :)

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

    You helped me survive an algo class 💯

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

    Really thanks for the detailed explanation, this video solved my questions watching Wiki of Quicksort

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

      Happy Holidays 🎉 Haha Thank you for your kind words! We'd love to offer you a 40% Off our exclusive lifetime membership just use the code CHEER40 - backtobackswe.com/checkout?plan=lifetime-legacy&discount_code=CHEER40

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

    I really felt the "move on" at 7:37.
    Btw, really helpful video!

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

    Dude, you're gifted! Thanks so much for helping us to get our dream jobs :D

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

    At 14:08, why did you swap your pivot with the i+1 value?

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

      I don't remember the specifics of this video - sorry im fast replying to comments. Hard to manage granular video details anymore

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

      the i value would be less than the pivot, and the i + 1 would be greater than the pivot, so he swapped the pivot with i + 1 so that the pivot would be in its final spot, and the less and greater values can then be sorted separately using recursion.

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

    6:10
    "what does i do?" - me trying to learn DS&A before @Back To Back SWE

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

    Thank you so much! You're a genius in your explanation way

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

    dude (or i should call you sir ) thanks for this highly valuable content with great video and audio quality

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

    man I love your videos, your teaching skills are amazing!

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

    This is so well presented. Instant subscribe. Thanks man.

  • @AlAmin-sl8eg
    @AlAmin-sl8eg 10 หลายเดือนก่อน

    the best teaching technique

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

    The more sorting videos I watch, the more unsorted my brain becomes.

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

    Very intuitive explanation! thanks...
    so how do we choose an optimal pivot element, so our quicksort operates in best/average-case time complexity. ?

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

    Subscribed! Very good explanations, please continue doing what you do.

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

    By median do you mean the median value of the array, or the median index?

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

    Thank you for your explanation so far. I am a little confused 10:04 when we swich the value i and j. in this process, why are we swich i and j? I don't see any point here

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

      Can you give a better timestamp? That one didn't capture the switch you reference

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

      @@BackToBackSWE oh sorry about that. 12:10 we switch 3 and 5

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

    Does this implementation use the Hoare partition scheme?

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

      im not sure what that is

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

      @@BackToBackSWE Thanks for this video and for replying. I don't know what it is either, which is why I asked. Apparently there are two common ways to partition: Lomuto's way or Hoare's way. en.wikipedia.org/wiki/Quicksort#Hoare_partition_scheme

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

      No. This one is Lomuto's partition scheme when you have two pointers (i and j) starting from the beginning.
      Hoare's partition is when we have two pointers: one starts from the beginning, second starts from the end.
      Looks like Hoare's partition is more preferable cause it makes 3 times less swaps than Lomuto's in average.
      cs.stackexchange.com/questions/11458/quicksort-partitioning-hoare-vs-lomuto
      www.geeksforgeeks.org/hoares-vs-lomuto-partition-scheme-quicksort/

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

      I asked myself the same question because there are different ways of quick sort implementation and they really differ. So it was a bit confusing for me at first why I see the same algorithm and different ways to implement it.

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

      @@snoopaku Thanks!

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

    U just saved my next exam

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

    all the swaps that you made when i was less than j is extra work right? b/c if you removed the swaps then you would still have the property of the lesser / greater halves with the pivot sandwiched

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

    a question when I am trying to replace the pivot = arr[right], with the middle point pivot choice (e.g. int pivot = arr[left + (right - left) / 2]). The reason is because middle point pivot can somehow optimize the time complexity, aka bigger chance to avoid the worst case than most-left OR most-right element. However, making this change will get the result messed up, can you explain the proper implementation for the middle-point-pivot in partition subroutine? thank you

  • @tony7948
    @tony7948 8 หลายเดือนก่อน

    Love the video, but isn't there a more optimized way to implement quick sort? In the code, it always picks the last item as the pivot, which is some cases with large inputs, it will timeout.

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

    You are a real man

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

    best explanation on quick sort !!

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

    20:50 - shouldnt it be 2 * ((n -1) / 2 - 1) , and in general: 2^i * ((n - 2^i + 1) / 2^i - 1)? ( Cause pivot from the previous step does not participate in the next step, so we get e.g. two arrays of length (n-1)/2 after first step. ) Anyways, I like the vid!

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

      im not sure i shot this a while back and dont remember the math and if I reviewed it it would be tedious. And thanks

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

    You're so cool ! Thank you for your videos, now I'm more confident about passing my exam :)

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

    6:11 - "what does I do?"
    Good fucking question

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

    great video. Could you please make a video for Subset Sum Problem (Print all subsets with given sum) Dynamic Programming?