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

Sdílet
Vložit
  • čas přidán 25. 03. 2019
  • Code & Problem Statement @ backtobackswe.com/platform/co...
    Free 5-Day Mini-Course: backtobackswe.com
    Try Our Full Platform: backtobackswe.com/pricing
    📹 Intuitive Video Explanations
    🏃 Run Code As You Learn
    💾 Save Progress
    ❓New Unseen Questions
    🔎 Get All Solutions
    Subscribe To Live Tech Offers: offerfeed.io
    Join Our Coaching Service: backtobackswe.com/coaching
    Question: Implement QuickSort. Explain how it works. Explain the best and worst cases.
    ++++++++++++++++++++++++++++++++++++++++++++++++++
    HackerRank: / @hackerrankofficial
    Tuschar Roy: / tusharroy2525
    GeeksForGeeks: / @geeksforgeeksvideos
    Jarvis Johnson: / vsympathyv
    Success In Tech: / @successintech
  • Věda a technologie

Komentáře • 406

  • @nano959
    @nano959 Před 5 lety +386

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

    • @BackToBackSWE
      @BackToBackSWE  Před 5 lety +19

      yeah

    • @alanliang9538
      @alanliang9538 Před 4 lety +29

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

    • @pulkitjain8135
      @pulkitjain8135 Před 4 lety +4

      @@alanliang9538 what do you mean by that??

    • @za3931
      @za3931 Před 3 lety +1

      @@pulkitjain8135 racism

    • @SpaceTimeBeing_
      @SpaceTimeBeing_ Před 3 lety +8

      @@BackToBackSWE Are these bot replies? Why are most of your replies so bland and short

  • @arvindg553
    @arvindg553 Před 3 lety +51

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

  • @brett9769
    @brett9769 Před 5 lety +98

    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  Před 5 lety +11

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

    • @arnabchakraborty246
      @arnabchakraborty246 Před 3 lety

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

  • @Jackado0dle
    @Jackado0dle Před rokem +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!!

  • @bhar92
    @bhar92 Před 5 lety +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  Před 5 lety +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.

  • @natachatomkinson1332
    @natachatomkinson1332 Před 3 lety +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!

  • @kennethmcausland2360
    @kennethmcausland2360 Před 3 lety +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.

  • @carsonstone6954
    @carsonstone6954 Před 4 lety +65

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

  • @pablorr24
    @pablorr24 Před 2 lety +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  Před 2 lety

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

  • @danielasanchez8151
    @danielasanchez8151 Před 4 lety +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!

  • @Titanman316
    @Titanman316 Před 3 lety +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.

  • @chrisxx9268
    @chrisxx9268 Před 4 lety +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!

  • @Gapo1994
    @Gapo1994 Před 4 lety +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

  • @sohailsaha7427
    @sohailsaha7427 Před 3 lety +2

    One of the best instructors on CZcams! Thank you for your contribution!

  • @BackToBackSWE
    @BackToBackSWE  Před 5 lety +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.

  • @supernugget98
    @supernugget98 Před 2 lety +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  Před 2 lety +1

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

  • @0x1h0b
    @0x1h0b Před 4 lety +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  Před 4 lety +1

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

  • @sulaimant5690
    @sulaimant5690 Před 3 lety

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

  • @ladieimp2416
    @ladieimp2416 Před 2 lety +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  Před 2 lety

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

  • @joy-sm5sl
    @joy-sm5sl Před 2 lety +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 :')

  • @roberttaylor8391
    @roberttaylor8391 Před 4 lety +1

    I have never commented on a CZcams 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 :)

  • @poojaguru2516
    @poojaguru2516 Před 5 lety +6

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

  • @SihaLoire
    @SihaLoire Před 4 lety +3

    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.

  • @MotoRider23605
    @MotoRider23605 Před 4 lety +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.

  • @juni1634
    @juni1634 Před 5 lety +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  Před 5 lety

      Aw, thanks

    • @dprophecyguy
      @dprophecyguy Před 5 lety +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 ?

  • @frankhu5418
    @frankhu5418 Před 4 lety +1

    Because you asked to. I'm posting again to let you know that you're helping me so much. Thank you for your help. The impact is huge on my life. These resources are some of the best most helpful videos on interviewing I've seen.

  • @ulziiko
    @ulziiko Před 4 lety +3

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

  • @timmytim9054
    @timmytim9054 Před 3 lety

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

  • @rogerrodulfo
    @rogerrodulfo Před rokem

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

  • @bowenzhang8714
    @bowenzhang8714 Před 3 lety

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

  • @calebwalls8668
    @calebwalls8668 Před 4 lety +1

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

  • @arvindg927
    @arvindg927 Před 4 lety +1

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

  • @lockitdrop
    @lockitdrop Před 4 lety +1

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

  • @gisellg7699
    @gisellg7699 Před 4 lety +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

  • @LaysaBit
    @LaysaBit Před rokem +1

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

  • @KanonetTI
    @KanonetTI Před 3 měsíci

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

  • @shruti6768
    @shruti6768 Před 5 lety +1

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

  • @mariasandru7
    @mariasandru7 Před 4 lety +2

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

  • @alimaher8386
    @alimaher8386 Před rokem

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

  • @tinkerneer
    @tinkerneer Před 5 lety +2

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

    • @BackToBackSWE
      @BackToBackSWE  Před 5 lety

      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.

  • @VachaVyas
    @VachaVyas Před 3 lety

    You are gifted! Thanks for making these concepts easy

  • @tarunsraina7243
    @tarunsraina7243 Před 4 lety +4

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

  • @svetashtrakh6565
    @svetashtrakh6565 Před 5 lety +1

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

  • @jayyupinhu9146
    @jayyupinhu9146 Před 5 lety +7

    give this man a gold metal! respect!

  • @alexeydemyanchuk
    @alexeydemyanchuk Před 2 lety

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

  • @ilya1131
    @ilya1131 Před 3 lety

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

  • @nanujhakree9057
    @nanujhakree9057 Před 5 lety +4

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

  • @YonatanVolsky
    @YonatanVolsky Před rokem

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

  • @AvinashKumar-pl7wc
    @AvinashKumar-pl7wc Před 4 lety +2

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

  • @ExarchiasGhost
    @ExarchiasGhost Před 4 lety +1

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

  • @StrayKev
    @StrayKev Před 5 lety +1

    TY so much. Clearest quicksort video on youtube

  • @winperec
    @winperec Před 4 lety +2

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

  • @dennislarsen5744
    @dennislarsen5744 Před 3 lety

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

  • @zachzulanas4125
    @zachzulanas4125 Před 4 lety +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

  • @alannah000
    @alannah000 Před rokem

    Finally understand quick sort! Thanks so much

  • @VillageJoker
    @VillageJoker Před 3 lety +2

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

  • @yardy88
    @yardy88 Před 3 lety

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

  • @jageenshukla4825
    @jageenshukla4825 Před 5 lety +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  Před 5 lety

      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 Před 5 lety +1

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

    • @BackToBackSWE
      @BackToBackSWE  Před 5 lety

      @@jageenshukla4825 haha

  • @songulmesale5264
    @songulmesale5264 Před 7 měsíci

    ı 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  Před 7 měsíci

      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

  • @lomoyang3034
    @lomoyang3034 Před 3 lety

    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 Před 3 lety

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

  • @im_parth
    @im_parth Před 4 lety +4

    Teaching is an art and you are an artist :)

  • @044_karan8
    @044_karan8 Před 4 lety +1

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

  • @Mines2013
    @Mines2013 Před 2 lety

    I love your videos! Keep up the good work!

  • @bonniwanamaker6296
    @bonniwanamaker6296 Před 5 lety +8

    Yet another great video. Where were you when I was learning this stuff in undergrad? :-)

    • @BackToBackSWE
      @BackToBackSWE  Před 5 lety +9

      In middle school I think...near corn fields 🌽🌽

  • @user-gh6sz6jn9v
    @user-gh6sz6jn9v Před 8 měsíci

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

    • @BackToBackSWE
      @BackToBackSWE  Před 7 měsíci

      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

  • @lextor99
    @lextor99 Před 4 lety +1

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

  • @augustusvonwatts555
    @augustusvonwatts555 Před 2 lety

    thank you for sharing. These videos have been a big help

    • @BackToBackSWE
      @BackToBackSWE  Před 2 lety

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

  • @bryanchau3772
    @bryanchau3772 Před 3 lety

    this channel deserves more than million subs

  • @heyjordn
    @heyjordn Před 4 lety +1

    This channel made me love algorithms again

  • @ricardocaballero6357
    @ricardocaballero6357 Před rokem

    Buddy I love your videos, thanks a lot

  • @riverlance9647
    @riverlance9647 Před 3 lety +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

  • @mattstyles4283
    @mattstyles4283 Před 3 lety

    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?

    • @mattstyles4283
      @mattstyles4283 Před 3 lety

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

  • @markusheinemann9258
    @markusheinemann9258 Před 3 lety

    Very nice explanation. Thank you!

  • @nzlotrfan
    @nzlotrfan Před 2 lety

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

  • @teji7723
    @teji7723 Před 4 lety +1

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

  • @MrTheBestJay
    @MrTheBestJay Před 4 lety +5

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

  • @aaron-uz6pc
    @aaron-uz6pc Před 3 lety

    Excellent explanation of Lamuto partitioning

  • @colinz7234
    @colinz7234 Před 4 lety +1

    love you sooo much, this video really helps!!!

  • @baxsdb
    @baxsdb Před 3 lety

    You helped me survive an algo class 💯

  • @hamsalekhavenkatesh3440

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

  • @vibekdutta6539
    @vibekdutta6539 Před 4 lety +2

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

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety

      nice

    • @vibekdutta6539
      @vibekdutta6539 Před 4 lety +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 Před 4 lety

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

    • @vibekdutta6539
      @vibekdutta6539 Před 4 lety

      There an explanation of the problem by Rachit Jain on CZcams 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  Před 4 lety

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

  • @shardulsemwal29
    @shardulsemwal29 Před 3 lety +1

    It is really much helpful and good then our professor lectures

  • @niekbeijloos8355
    @niekbeijloos8355 Před rokem

    Very well explained, thank you!

    • @BackToBackSWE
      @BackToBackSWE  Před rokem

      Thank you! Please enjoy a special code from us - backtobackswe.com/checkout?plan=lifetime-legacy&discount_code=niekbeijloos8355 🎉

  • @arjunkramadhati8910
    @arjunkramadhati8910 Před 3 lety

    Thank you. Amazing video :)

  • @marykeshkha2282
    @marykeshkha2282 Před 4 lety +1

    SERIOUSLY!!!! Thank youuuu, u'r the best ❤️❤️❤️

  • @marcousosewelle5501
    @marcousosewelle5501 Před 4 lety +1

    Brilliant work!!!! Absolutely brilliant. Thank you :-)

  • @vighneshk509
    @vighneshk509 Před 4 lety +1

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

  • @puperhacker2150
    @puperhacker2150 Před 5 lety +2

    Congrats for 10k!

  • @timetolive4869
    @timetolive4869 Před 4 lety +1

    Amazing video! listen you are something special. I really wanted to open a youtube channel about computer siecne and programming in my native language(Hebrew - I'm from Israek :) ), and you really inspire me to actually try and do that.
    Thank you for everything!

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety

      You can do whatever you want. This all took about 1.5 years so like...if you believe and the world has the need for it you will succeed. Like srs.

  • @joey6743
    @joey6743 Před 4 lety +1

    Thank you for all that explanation. 🤗🤗🤗

  • @aryankhare9393
    @aryankhare9393 Před 3 lety

    Such a great explanation

  • @rohangarg5473
    @rohangarg5473 Před 4 lety +1

    best explanation on quick sort !!

  • @PenStab
    @PenStab Před 2 lety +1

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

  • @user-bg7yp9wg6z
    @user-bg7yp9wg6z Před 6 měsíci

    Any new videos? Your explanation is so good!

  • @saurabhjindal2775
    @saurabhjindal2775 Před 4 lety +2

    Best content I have ever encountered

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety +1

      thx

    • @saurabhjindal2775
      @saurabhjindal2775 Před 4 lety +1

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

    • @BackToBackSWE
      @BackToBackSWE  Před 4 lety

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

  • @gilt9936
    @gilt9936 Před 5 lety +1

    thank you very much, very clear explanation.

  • @AlAmin-sl8eg
    @AlAmin-sl8eg Před 5 měsíci

    the best teaching technique

  • @BhupendraYadav-li4ts
    @BhupendraYadav-li4ts Před 5 lety +1

    You are just Awesome Bro. Love you.

  • @charliel7041
    @charliel7041 Před 3 lety

    this is an awesome video!

  • @Victor-cg4hx
    @Victor-cg4hx Před rokem

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