Merge Sort Algorithm in Java - Full Tutorial with Source

Sdílet
Vložit
  • čas přidán 10. 04. 2021
  • Complete Java course: codingwithjohn.thinkific.com/...
    Full source code available HERE: codingwithjohn.com/merge-sort...
    Coding the Merge Sort algorithm in Java with recursion! Can we sort 100,000,000, or even 1 billion ints?
    This is a slightly more complex recursive Java coding lesson tutorial, where we'll use recursion to write our own implementation of VERY efficient Merge Sort sorting algorithm in Java.
    Merge Sort is a fantastic sorting algorithm, a little more advanced but great algorithm for intermediate Java students to learn.
    Learn or improve your Java by watching it being coded live!
    Hey, I'm John! I'm a Lead Java Software Engineer who has been in the industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java developers.
    Let me know what else you'd like to see!
    Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
    📕 THE best book to learn Java, Effective Java by Joshua Bloch
    amzn.to/36AfdUu
    📕 One of my favorite programming books, Clean Code by Robert Martin
    amzn.to/3GTPVhf
    🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
    www.audibletrial.com/johnclean...
    🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
    bit.ly/3QPNGko
    📹Phone I use for recording:
    amzn.to/3HepYJu
    🎙️Microphone I use (classy, I know):
    amzn.to/3AYGdbz
    Donate with PayPal (Thank you so much!)
    www.paypal.com/donate/?hosted...
    ☕Complete Java course:
    codingwithjohn.thinkific.com/...
    codingwithjohn.com
  • Věda a technologie

Komentáře • 303

  • @akosdanielbollok4956
    @akosdanielbollok4956 Před 2 lety +52

    This is pure gold! I wish you did a full Data structures&algorithms course, that would be awesome.

  • @metdelta1
    @metdelta1 Před 2 lety +181

    Perhaps the BEST explanation of Merge Sort out there. 👍🏻
    The code along with variable names, justifies the natural thinking of the human mind.
    Thanks a lot ❤️
    Subscribed ✅
    Best wishes and hope your channel gets all the love and support it deserves.

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

      Agreed, he explained it clearly and step by step, such a great explanation!!!

  • @nguyencongthaisonk14hcm57
    @nguyencongthaisonk14hcm57 Před 2 lety +36

    I'm very weak in algorithms. From watching your video, the tutorial is very easy to understand. I understand how merge sort works. Thank you very much from the Vietnamese guy !

    • @CodingWithJohn
      @CodingWithJohn  Před 2 lety +8

      Thanks Vietnamese Guy! Very glad I was able to help!

  • @mir.9805
    @mir.9805 Před rokem +31

    I can't believe I've watched this entire video and without being bored. I can't even sit in class for 15 minutes without going to sleep and I'm literally watching this at 2:32am in bed.

  • @moeal5110
    @moeal5110 Před 2 lety +52

    I watched and read neumors explanations about this but only after watching your video I was able to understand each line and now I can see it in my brain's eyes. I also dreamt about it. Thanks a lot! Please do more

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

    I had to watch more than once to really absorb the info. It still is a lot less time and money than it costs me to listen to lectures at my university. Thank you for taking the time to make this video!

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

    Seriously I love the content you make, its made my learning much more better. You're so relaxed and calm about the way you explain your code. Good job!!

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

    I can't thank you enough for this clean explanation. I haven't been able to understand this algorithm until I stumbled on your video. Now I practically know what each line of code means. You're a genius!!

  • @J-wm4ss
    @J-wm4ss Před 2 lety +3

    Thanks! This makes SO MUCH MORE SENSE than other explanations!

  • @LTZMSYAL
    @LTZMSYAL Před rokem +1

    John you did an awesome job in this video! You're the best course I could find on the merge sort algorithm. I really want to thank you from France for that. Keep up the good work :)

  • @akshaypatel9982
    @akshaypatel9982 Před 2 lety +9

    Wow, the first explanation that made complete sense with 0 confusion.Thank you very much! Wish you were my teacher back in college lol

  • @Nerdymelreads
    @Nerdymelreads Před rokem

    You do not know how much I looked around for a better explanation. You nailed it. Earned a new subbie.

  • @sajanarora245
    @sajanarora245 Před 2 lety

    Gave the link to this in the comments of every video I watched to understand merge sort because this is the best explanation of Merge sort. Thanks a lot man!!! Subscribed

  • @franklinoduro7274
    @franklinoduro7274 Před 2 lety

    Hands down this is the best sorting algorithm video i have seen on youtube. Thanks John

  • @sekharsamanta6266
    @sekharsamanta6266 Před 9 měsíci

    Hi Mr. John, I've seen so many videos on different algorithms of other people but your explanation is crystal clear and unique

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

    This video is insanely well made!! Good job :)

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

    Absolutely brilliant explanation! I was so confused for a school assignment on why the last two while loops exist in the code. Turns out it was just cleanup!

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

    What an excellent explanation !! Simple, clear and concise. Thank you very much.

  • @raoulkid
    @raoulkid Před 2 lety

    The only person on yt that actually explained the merge subroutine properly, thanks, +1 sub

  • @mahmoudmoussa6722
    @mahmoudmoussa6722 Před 2 lety

    For such comprehensive&best merge sort out there, you won a subscriber. Thanks.

  • @AamirBilalm
    @AamirBilalm Před 2 lety

    Great work John, really appreciate it. Highly undervalued channel. Hope you get the support you deserve.

  • @crazyedits6948
    @crazyedits6948 Před 2 lety

    I am looking for this kind of explanation for a long time. Thank you so much john for this extraordinary tutorial. Loved it and subscribed immediatley.

  • @AceNinja1101
    @AceNinja1101 Před 2 lety +8

    Very informative video! Really could have used this back when I was in college lol. Also just attempted to run this with 1 billion elements and took about 8 and half minutes using C# for anyone who's curious!

  • @rodrigosalomao3835
    @rodrigosalomao3835 Před rokem

    I've finilly learned this. Thanks a lot dude!

  • @haidaralihammoud2686
    @haidaralihammoud2686 Před 7 měsíci +1

    That is by far the best explanation out there! Amazing technique of teaching and breaking it down. Thanks a lot!

  • @kevalkrishna4134
    @kevalkrishna4134 Před rokem

    Such a calm and beautiful explanation for merge sort algo , loved it. And yeah ,you earned a new subscriber.

  • @BlueHat1
    @BlueHat1 Před 11 měsíci +1

    This is the best explanation of merge sort I've ever heard. Thank you!!

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

    Finally I got this!!!
    Thank you!!!
    The best explanation so far!!!

  • @Qongrat
    @Qongrat Před rokem

    Loved every second of it!

  • @sujanreddy9770
    @sujanreddy9770 Před rokem

    Whenever I need to refer algorithms I will directly watch your videos thanks for explaining so clearly.

  • @nosehad5486
    @nosehad5486 Před rokem

    great, you are the only one that explained it in a way that i understand

  • @kunaldutta7096
    @kunaldutta7096 Před rokem

    Very good illustration and easy to understand steps. I have stumbled upon the videos of John by accident, and I am really happy that I have. Kudos to you. subscribed :) .

  • @RanVargas
    @RanVargas Před 29 dny

    Hey Man, I just wanted to comment and say I really thank you, I hadn't fully understood Merge Sort at least on the Merge step, but now I am kind of like grasping it, thank you for explaining with time and detail.

  • @davidl6797
    @davidl6797 Před 2 měsíci

    Great explanation John! It was easy to learn and understand this algorithm with your lesson!

  • @ferhatf9385
    @ferhatf9385 Před 2 lety

    thanks alot i was reall struggling to learn merging sorted arrays ,but this video rwas eally helped me then all the others that i watched

  • @kishordige9721
    @kishordige9721 Před rokem

    Best one, getting addicted to your videos!!!

  • @natnal9587
    @natnal9587 Před rokem

    Honestly, this is the best video I have ever seen about merge sort.

  • @michaellese3604
    @michaellese3604 Před 2 lety

    Great video, super easy to follow and made understanding merge sort way easier

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

    I was so frustrated and sad about not understanding the merge sort. Your explnation is very clear, made my day. Thanks a lot! :)

  • @mohammadahmedragab837
    @mohammadahmedragab837 Před 2 lety

    I love your easy amazing explanation of the code and the concept, thank you so much ❤️

  • @user-xc9ne4oq3r
    @user-xc9ne4oq3r Před 2 lety

    This is really great! you make it really easy. Thank you for your work!

  • @ayyanchira
    @ayyanchira Před 2 měsíci

    Really good explanation! Thanks John! Your videos are spot on!

  • @willemvanderveen7567
    @willemvanderveen7567 Před 2 lety

    Keep it up man, your videos are absolutely amazing

  • @wasekasi
    @wasekasi Před 2 lety

    This is by far the best sorting app I've seen someone code. Awesome.

  • @pelinegriboyun948
    @pelinegriboyun948 Před 2 lety

    awesome video! couldn't understand merge sort at all before this explanation, thank you so much

  • @neurohan
    @neurohan Před rokem

    You are, without a doubt, one of the most talented educators I've come across (both online and offline).

  • @lyn8964
    @lyn8964 Před 2 lety

    Your videos let me fall in love with java! So much Java fun!

  • @mariusandries4103
    @mariusandries4103 Před 2 lety

    Thank you, this explanation is so clear and short.

  • @trentlandon9033
    @trentlandon9033 Před rokem

    You really made it look so easy and understandable

  • @stacy623
    @stacy623 Před 2 lety

    This is really helpful! Thank you for your work!

  • @_Anna_Nass_
    @_Anna_Nass_ Před 2 lety

    Thank you so much! This was super helpful for my assignment. I feel like I really understand now.

  • @HisExcellencyAKK
    @HisExcellencyAKK Před 2 lety +15

    Great work! possibly memory can be improved a bit by passing indices (start, mid, end) into split subroutine instead of sub arrays. We would only need an auxiliary space of size n at merge subroutine. Since merge subroutine happens after split subroutines, the maximum auxiliary space that will be needed is n instead of n*log(n).

  • @igor9919
    @igor9919 Před 4 měsíci

    This is by far the best tutorial for merge sort, thanks so much

  • @HelicopterRidesForCommunists

    You are such a good teacher. Very talented at communicating information and concepts. 1 million sorted thanks to you.

  • @TuanBuianonymous
    @TuanBuianonymous Před 2 lety

    my english is not good to understand all words you said but when i look into your code i absolutely understand all, thank you very much.

  • @georgikyshenko4380
    @georgikyshenko4380 Před 2 lety

    That explanation was AMAZING ! Thank you !

  • @yuselina8769
    @yuselina8769 Před 2 lety

    This video is amazing! Thank you for your explanation!!

  • @user-pb6ps2mb4y
    @user-pb6ps2mb4y Před rokem

    Awesome explanation! As usual!!!
    Thank you, John, so much!!!!
    You're the best!!😊

  • @renathanobre
    @renathanobre Před 2 lety

    love this tutorial, thanks for the amazing explanation and for sharing it

  • @melissanicole4030
    @melissanicole4030 Před rokem

    Thanks John! Very clear explanation

  • @fakhrulmb
    @fakhrulmb Před 2 lety

    Subscribed! Helped me through my Algo and data structure unit!! Best coding tutorial out here!!

  • @Nicolasv67
    @Nicolasv67 Před 2 lety

    This really helped me. Many many thanks!!!

  • @wilsvenleong96
    @wilsvenleong96 Před 2 lety

    Definitely the best explanation out there. I'm subscribed.

  • @eduardohenriquedeassis9729

    Hey Bro, it is for sure, one of the best tutorial about this subject I ever saw, I was struggling to understand it, but now it´s clearwater!!!!!
    Thanks for that.
    Greetings from Brazil.

  • @juanjaureguireyes
    @juanjaureguireyes Před 2 lety

    Hi John! Thanks a lot for your video. Quite helpful for my C++ programming assignment. Cheers!

  • @tulioperez6011
    @tulioperez6011 Před 2 lety

    Amazing teaching skills - perfection execution

  • @jeremiahnji6
    @jeremiahnji6 Před 2 lety

    Super clean coding! Thank you

  • @seyedaliroshan2386
    @seyedaliroshan2386 Před 2 lety

    I liked the way u describe the stuff so clear and nice

  • @jeremy-hq9de
    @jeremy-hq9de Před 5 měsíci

    Helped alot, thanks!

  • @viveks1170
    @viveks1170 Před 9 měsíci

    straight to my brain .thanks!

  • @talexvi
    @talexvi Před rokem

    This is super helpful and very well presented! Thanks!

  • @Eww...NotTheHumansAgain

    Thank you very much for this clear like crystal explanation!

  • @studyingit9762
    @studyingit9762 Před rokem

    Great video THANKS JOHN!!

  • @elshaterhassansaber7644
    @elshaterhassansaber7644 Před 3 lety +40

    I've been searching for a good explanation and a good clean code
    but luckily !! i found both in one video
    you're an amazing guy

  • @makeitsimple4734
    @makeitsimple4734 Před 2 lety

    Thank you so much for the explanation. You’re a life saver 😄

  • @EduardoFerreira6
    @EduardoFerreira6 Před 2 lety

    Thanks, your explanation is very clear.

  • @sagarrawal7740
    @sagarrawal7740 Před rokem

    seriously one of the best merge sort explanation

  • @lyn8964
    @lyn8964 Před 2 lety

    Good job, i really love this video! Thx:)

  • @shriharshbankapur9666
    @shriharshbankapur9666 Před 2 lety

    Thank u john for putting it in my head!
    u got a lifetime subscriber.

  • @dotherap
    @dotherap Před rokem

    Amazing guide, thank you.

  • @dreivonfunf9489
    @dreivonfunf9489 Před 10 měsíci

    Thank you for this great tutorial!

  • @sriplano748
    @sriplano748 Před rokem

    Thanks John for a real good explanation of Merge Sort algorithm with code.

  • @madhavansan008
    @madhavansan008 Před 2 lety

    You are born to teach ! , Expecting more and more videos

  • @juanrada1940
    @juanrada1940 Před 2 lety

    Fantastic video! "If you want to be cool you can..." is priceless!

  • @asmaasadek7735
    @asmaasadek7735 Před 2 lety

    Just wanted to tell you, you are one of the best!

  • @cesar-on-youtube
    @cesar-on-youtube Před rokem

    You're an excellent teacher. Thank you.

  • @vikasjaiswal3247
    @vikasjaiswal3247 Před 2 lety

    Excellent explanation John

  • @timurboltaev8688
    @timurboltaev8688 Před rokem

    Thank you. Watched the video. Went to the code. Copied it down with a pen on paper to understand better. Rewatched the video. I think I have grasped it.

  • @gokul_sankar7939
    @gokul_sankar7939 Před rokem

    Really awesome john🎉!❤

  • @thefrightningflame8972

    worked amazing!

  • @athewhitedragon
    @athewhitedragon Před 2 lety

    the best...this algorithm stuck in my mind hardly

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

    Thank you so much for this!

  • @hehhehdummy
    @hehhehdummy Před rokem

    Best lecture on the subject I've come across. Love the demo at the end too. I know there's a way to write this algorithm with 1 helper array (instead of creating new arrays all the time), it seems not to have mattered too much.

  • @grozageorge2887
    @grozageorge2887 Před 9 měsíci

    Awesome exaplained and easy to understand 😇😊

  • @fardinshuvro3717
    @fardinshuvro3717 Před rokem

    Awesome expalinations!

  • @tijilparmar5758
    @tijilparmar5758 Před rokem

    Really nicely explained

  • @thetruthsayer8347
    @thetruthsayer8347 Před 2 lety

    I like this. I wish there more algorithm tutorials based in java. Please make more.

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

    You are Amazing broo, just keep going, I love it.

  • @jaydeeppawar1720
    @jaydeeppawar1720 Před 2 lety

    beautifully explained loved that u went all the way upto a billion!! :)

  • @ShivaKaalaCreations
    @ShivaKaalaCreations Před rokem

    Sir really it's very helpful, thanks.