Learn Merge Sort in 13 minutes 🔪

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ก.ค. 2021
  • Merge sort algorithm tutorial example explained
    #merge #sort #algorithm
    // merge sort = recursively divide array in 2, sort, re-combine
    // run-time complexity = O(n Log n)
    // space complexity = O(n)
    music credits 🎼:
    ===========================================================
    Title: Wallflowers
    Artist: Bad Snacks
    Link: • bad snacks: TH-cam Au...
    ===========================================================
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @BroCodez
    @BroCodez  2 ปีที่แล้ว +327

    This video took me THREE WEEKS to produce! Ya'll better smash that like button for me! lol
    public class Main{

    public static void main(String args[])
    {
    // merge sort = recursively divide array in 2, sort, re-combine
    // run-time complexity = O(n Log n)
    // space complexity = O(n)

    int[] array = {8, 2, 5, 3, 4, 7, 6, 1};

    mergeSort(array);

    for(int i = 0; i < array.length; i++){
    System.out.print(array[i]+ " ");
    }
    }
    private static void mergeSort(int[] array) {

    int length = array.length;
    if (length

    • @syllight9053
      @syllight9053 2 ปีที่แล้ว +38

      Don't worry bro, I smashed the like button, plus I contacted the president to set a direct nuclear launch to the like and subscribe button as well!

    • @BroCodez
      @BroCodez  2 ปีที่แล้ว +16

      @@syllight9053 Thank you Syllight!

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

      I already did my big bro :D If we both belonged to only 1 family u would be my bigger bro :D

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

      3 weeks making this *AND THERE'S A DISLIKE????*

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

      Hi bro plsae reques Tutorial Python AndroidHelper. Music, recorder, voice mix, microfon. Call phone, game, calculator, google voice recorder, and others..
      🙏🙏🙏🙏🙏🙏 Plsee

  • @mayawhocodes3092
    @mayawhocodes3092 ปีที่แล้ว +247

    The way you broke this down into simple terms with visuals and everything, amazing. I'm not a bro, but I do code. And this was lit. Thank you.

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

      No. You are a bro now!!

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

    Best explanation I've seen so far. The rundown at the beginning really helps. Thank you

  • @coltonbailey8873
    @coltonbailey8873 2 ปีที่แล้ว +57

    You are single-handedly teaching me programming/computer science. Thank you. Never change your teaching structure, because this method works really well.

  • @Jathamus
    @Jathamus ปีที่แล้ว +17

    I knew when I saw "Bro Code" it would be a beautifully simple video.
    What you did that the other videos I watched failed to do was walk through the sort / merge in the order that it would actually happen.
    The other videos were doing it by rows and not the actual order that it happens in. Thank you ! That is what made it click for me.
    I am now subscribed !

  • @smokinginthefishroom
    @smokinginthefishroom 11 หลายเดือนก่อน +2

    The best merge sort explanation on TH-cam. Watched like 5 other videos but only this explained how the merge part of merge sort actually works! Liked and subscribed.

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

    You made mergeSort look so simple and easy, thank you so much!

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

    You are a great tutor sir, I appreciate, I was failing to understand this all along, but just because of your video, I feel confident enough

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

    Thank you man!!! Finally I have found the best explanation of merge sort! You really helped us a lot.
    I've alredy smashed the like button, you deserve it bro!!!

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

    Trying to make these algorithms with blueprint nodes in UE5, and following along with your code is also helping me translate code jargon into blueprint equivalents. Thank you for sharing

  • @GamerOverThere
    @GamerOverThere 8 หลายเดือนก่อน +10

    Bro, you are a legend. My professor went over merge sort for 1 1/2, and I was left confused. I watched a Harvard lecture video on it, still confused. Asked chatGPT about individual components (not to cheat but to have it explain each step to me, I want to understand this) and it was spewing nonsense. But your video made it finally click. Thanks bro! Liked and subscribed

  • @raywei1701
    @raywei1701 6 หลายเดือนก่อน +1

    So clear. my professor did not have enough time to go over this in class. Now I understand everything about merge sort.

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

    Clearly explanation and demonstration with merge sort, great work!!!
    Can,t wait for more CS videos.

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

    Best merge sort tutorial I've seen, thank you

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

    it'd be really helpful if you continue this playlist!!!
    thanks in advance

  • @sanskarsongara2592
    @sanskarsongara2592 2 ปีที่แล้ว +9

    Idk you sounds more confident in recent new videos, keep going homie you still gotta reach more people👍

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

    The best merge sort explanation! Thank you so much.

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

    Probably the best video i've seen so far to explain Mergesort, i think i finally got it!

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

    top content as always. No one more understandable than Bro! (I hope you doin good on your break!!!)

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

    Thank you for the beautifully elegant explanation that didn't require the viewer to have a PhD. You are one talented bro. Keep it up!

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

    Needed this for my interview :))) thank you!

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

    Started your Java playlist love your tricks to teach... Appreciate from another fellow BRO.

  • @NH-ij8dz
    @NH-ij8dz หลายเดือนก่อน

    Great video. I needed to implement this in C for a CS class and this video explained it in much clearer and easier to follow way than the so called experts who are being paid 6 figures a year to teach this to me. Ty bro.

  • @user-hi8qt6rq4b
    @user-hi8qt6rq4b 9 หลายเดือนก่อน +2

    Good job! It is really easy to understand the algorithm with this video, thank you

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

    Wow! this is a good tutorial. Thank you very much for taking the time to put it together! Well Done!

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

    You are the best Bro I never had. 2 years have gone by, but this is still amazing.

  • @arturofuentes2230
    @arturofuentes2230 18 วันที่ผ่านมา

    Great video man, I understood everything so quickly, thank you so much and keep coding bro

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

    Best explanation of merge sort so far!

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

    You just made my computer science assignment a whole lot easier lol. Thank you.

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

    a concise and helpful tutorial, thanks Bro!

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

    Wow you are one of the best TH-camrs to explain algorithms

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

    Really good explanation of merge sort! It helped heaps!

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

    very helpful video...watching all your sorting videos and learning from it...thanks BRO

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

    Thanks man! , because of you , i can skip the tough work of learning, hehe, and straight jump into implementing algorithms

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

    Thank you!! this was very thorough and clear!!

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

    You earned a sub! Awesome explanation

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

    Recursive algorithms are the bane of my existence.

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

    No words can explain my appreciation
    Thank you, sir 🏆🏆🏆🏆

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

    After 2 years this is still very useful i understand everything now .
    even though i don't know how to use java i've just learned c++ but everything is clear now

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

    Good video, not too long, not too short. Great job.

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

    Thank you so much for making this video!

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

    Thanks man!!! Great video🤗

  • @Crystal-gs4gu
    @Crystal-gs4gu ปีที่แล้ว

    Thank you for saving me from my final test. You are the best teacher

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

    great job = thank you so much
    please continue🥰

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

    Thanks for your explain! it's very helpful to understand!

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

    thanks for these videos ,we need them alot

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

    thanks a lot bro this solution and your explanation is awesome:)

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

    WoW! Gorgeous video! Mergesort can be hard to understand. Great, great job!

  • @DJSaez-ll8or
    @DJSaez-ll8or 9 วันที่ผ่านมา

    Really helpful video, thank you!

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

    Thank you for your amazing videos!!!❤️❤️❤️

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

    Thanks for another great video bro.

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

    Thanks for the informative video

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

    Thank you brother!!!

  • @neophilosophy1764
    @neophilosophy1764 14 วันที่ผ่านมา

    Nice. Thanks for the video!

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

    great work, well explained!

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

    First of all I just wanted to let you know that thanks to your java section I landed a job as a java developer.
    So ...from the bottom of my heart, thank you, keep up the good work!
    On the other hand, a question for this video: what if the array has an odd length ?

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

    If you ever publish a book, I'd be the first one to buy it. Excellent work, Bro. 🙏

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

    yo bro thanks bro, great stuff bro from one bro to another bro

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

    Thanks for the content !

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

    omg, I love the music. Good stuffs brah =)))))))))))))

  • @ernestselman3955
    @ernestselman3955 5 หลายเดือนก่อน +1

    Hey Bro Code, thanks for the video. It really helped me learn MergeSort. I have a question. In your implementation, would the memory requirements be nlog(n) or n? Since you are creating copies of the arrays as you go down recursively, that would be adding to the memory. If I make the mergeSort method by passing a reference of the original array and indexes representing the start and end of left and right subarrays, then only create the required copies in the merge method before backtracking, wouldn't the maximum memory used be the last step where we would have copies of the entire original array and therefore memory utilization would be 2n or just n?

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

    Thankyouuuuusomuch, your video really helps our group "MEMANG".

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

    That's terrific! I'm working my way thru your videos. Wish I found your channel earlier.

  • @mike-fl9xi
    @mike-fl9xi ปีที่แล้ว

    gg bro. super helpful, nice break down

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

    Like button smashed..... thanks bro

  • @AN-rz7bs
    @AN-rz7bs 5 หลายเดือนก่อน

    Thanks, this video really helped me!

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

    thanks for the class!!!!

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

    The best video ever .....love u man....

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

    Thanks Bro, you are the best!

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

    Thanks for explaining merge sort!

  • @radicalsaled5756
    @radicalsaled5756 10 หลายเดือนก่อน +1

    nice job, simple explanation of a long algorithm

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

    u are the best ,bro!

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

    this the most helpful channel thank u a lot🥰🥰

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

    amazingly explained

  • @sahu_SuMiT
    @sahu_SuMiT 20 วันที่ผ่านมา

    awesome, as always....

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

    You are a better teacher than my dsa ones!

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

    nice vid bro

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

    Great video! Now I understand it :)

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

    شغل جامد يسطى

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

    legendary explanation

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

    awesome explanation bro

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

    Hey bro thanks for the video.

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

    Thank you bro💓

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

    Awesome and simple

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

    nice. very nice. If you didnt work as a sw engineer, my professors were really as bad as i knew they were. good job.

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

    Nice explanation

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

    amazing!

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

    Thank you

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

    Nice explanation. Now it does not seem so complicated.

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

    Bro king👑

  • @muhammedelsayed.radwan
    @muhammedelsayed.radwan 9 หลายเดือนก่อน

    Amazing 👏

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

    thanks for the video :)

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

    Great video. Thanks

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

    thank you, sir

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

    Thanks. I tried my own implementation but for some reason it didn't work so I just followed along with yours.

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

    Big fan bro

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

    Nice class

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

    Thanks!

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

    i love you brocode 😻

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

    thanks bro 🙏