Merge Sort Algorithm in Java - Full Tutorial with Source

Поділитися
Вставка
  • Опубліковано 10 кві 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
  • Наука та технологія

КОМЕНТАРІ • 303

  • @akosdanielbollok4956
    @akosdanielbollok4956 2 роки тому +52

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

  • @metdelta1
    @metdelta1 2 роки тому +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 2 роки тому +1

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

  • @nguyencongthaisonk14hcm57
    @nguyencongthaisonk14hcm57 2 роки тому +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  2 роки тому +8

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

  • @mir.9805
    @mir.9805 Рік тому +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 2 роки тому +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 2 роки тому +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 2 роки тому +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 2 роки тому +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 2 роки тому +3

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

  • @LTZMSYAL
    @LTZMSYAL Рік тому +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 2 роки тому +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 Рік тому

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

  • @sajanarora245
    @sajanarora245 2 роки тому

    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 2 роки тому

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

  • @sekharsamanta6266
    @sekharsamanta6266 9 місяців тому

    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 2 роки тому +1

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

  • @kosaken1207
    @kosaken1207 2 роки тому +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 2 роки тому +1

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

  • @raoulkid
    @raoulkid 2 роки тому

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

  • @mahmoudmoussa6722
    @mahmoudmoussa6722 2 роки тому

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

  • @AamirBilalm
    @AamirBilalm 2 роки тому

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

  • @crazyedits6948
    @crazyedits6948 2 роки тому

    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 2 роки тому +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 Рік тому

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

  • @haidaralihammoud2686
    @haidaralihammoud2686 7 місяців тому +1

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

  • @kevalkrishna4134
    @kevalkrishna4134 Рік тому

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

  • @BlueHat1
    @BlueHat1 11 місяців тому +1

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

  • @doncilaarcadie
    @doncilaarcadie 2 роки тому +1

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

  • @Qongrat
    @Qongrat Рік тому

    Loved every second of it!

  • @sujanreddy9770
    @sujanreddy9770 Рік тому

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

  • @nosehad5486
    @nosehad5486 Рік тому

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

  • @kunaldutta7096
    @kunaldutta7096 Рік тому

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

  • @davidl6797
    @davidl6797 2 місяці тому

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

  • @RanVargas
    @RanVargas Місяць тому

    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.

  • @ferhatf9385
    @ferhatf9385 2 роки тому

    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 Рік тому

    Best one, getting addicted to your videos!!!

  • @natnal9587
    @natnal9587 Рік тому

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

  • @michaellese3604
    @michaellese3604 2 роки тому

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

  • @Yersinia1988
    @Yersinia1988 2 роки тому +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 2 роки тому

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

  • @user-xc9ne4oq3r
    @user-xc9ne4oq3r 2 роки тому

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

  • @ayyanchira
    @ayyanchira 2 місяці тому

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

  • @willemvanderveen7567
    @willemvanderveen7567 2 роки тому

    Keep it up man, your videos are absolutely amazing

  • @wasekasi
    @wasekasi 2 роки тому

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

  • @pelinegriboyun948
    @pelinegriboyun948 2 роки тому

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

  • @neurohan
    @neurohan Рік тому

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

  • @lyn8964
    @lyn8964 2 роки тому

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

  • @mariusandries4103
    @mariusandries4103 2 роки тому

    Thank you, this explanation is so clear and short.

  • @trentlandon9033
    @trentlandon9033 Рік тому

    You really made it look so easy and understandable

  • @stacy623
    @stacy623 2 роки тому

    This is really helpful! Thank you for your work!

  • @_Anna_Nass_
    @_Anna_Nass_ 2 роки тому

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

  • @HisExcellencyAKK
    @HisExcellencyAKK 2 роки тому +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 4 місяці тому

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

  • @HelicopterRidesForCommunists
    @HelicopterRidesForCommunists 2 роки тому

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

  • @TuanBuianonymous
    @TuanBuianonymous 2 роки тому

    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 2 роки тому

    That explanation was AMAZING ! Thank you !

  • @yuselina8769
    @yuselina8769 2 роки тому

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

  • @user-pb6ps2mb4y
    @user-pb6ps2mb4y Рік тому

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

  • @renathanobre
    @renathanobre 2 роки тому

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

  • @melissanicole4030
    @melissanicole4030 Рік тому

    Thanks John! Very clear explanation

  • @fakhrulmb
    @fakhrulmb 2 роки тому

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

  • @Nicolasv67
    @Nicolasv67 2 роки тому

    This really helped me. Many many thanks!!!

  • @wilsvenleong96
    @wilsvenleong96 2 роки тому

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

  • @eduardohenriquedeassis9729
    @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 2 роки тому

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

  • @tulioperez6011
    @tulioperez6011 2 роки тому

    Amazing teaching skills - perfection execution

  • @jeremiahnji6
    @jeremiahnji6 2 роки тому

    Super clean coding! Thank you

  • @seyedaliroshan2386
    @seyedaliroshan2386 2 роки тому

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

  • @jeremy-hq9de
    @jeremy-hq9de 5 місяців тому

    Helped alot, thanks!

  • @viveks1170
    @viveks1170 9 місяців тому

    straight to my brain .thanks!

  • @talexvi
    @talexvi Рік тому

    This is super helpful and very well presented! Thanks!

  • @Eww...NotTheHumansAgain
    @Eww...NotTheHumansAgain Рік тому

    Thank you very much for this clear like crystal explanation!

  • @studyingit9762
    @studyingit9762 Рік тому

    Great video THANKS JOHN!!

  • @elshaterhassansaber7644
    @elshaterhassansaber7644 3 роки тому +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

    • @jaydeeppawar1720
      @jaydeeppawar1720 2 роки тому

      true a clean code is a must for understanding ....

  • @makeitsimple4734
    @makeitsimple4734 2 роки тому

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

  • @EduardoFerreira6
    @EduardoFerreira6 2 роки тому

    Thanks, your explanation is very clear.

  • @sagarrawal7740
    @sagarrawal7740 Рік тому

    seriously one of the best merge sort explanation

  • @lyn8964
    @lyn8964 2 роки тому

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

  • @shriharshbankapur9666
    @shriharshbankapur9666 2 роки тому

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

  • @dotherap
    @dotherap Рік тому

    Amazing guide, thank you.

  • @dreivonfunf9489
    @dreivonfunf9489 10 місяців тому

    Thank you for this great tutorial!

  • @sriplano748
    @sriplano748 Рік тому

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

  • @madhavansan008
    @madhavansan008 2 роки тому

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

  • @juanrada1940
    @juanrada1940 2 роки тому

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

  • @asmaasadek7735
    @asmaasadek7735 2 роки тому

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

  • @cesar-on-youtube
    @cesar-on-youtube Рік тому

    You're an excellent teacher. Thank you.

  • @vikasjaiswal3247
    @vikasjaiswal3247 2 роки тому

    Excellent explanation John

  • @timurboltaev8688
    @timurboltaev8688 Рік тому

    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 Рік тому

    Really awesome john🎉!❤

  • @thefrightningflame8972
    @thefrightningflame8972 Рік тому

    worked amazing!

  • @athewhitedragon
    @athewhitedragon 2 роки тому

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

  • @harveers820
    @harveers820 7 місяців тому

    Thank you so much for this!

  • @hehhehdummy
    @hehhehdummy Рік тому

    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 9 місяців тому

    Awesome exaplained and easy to understand 😇😊

  • @fardinshuvro3717
    @fardinshuvro3717 Рік тому

    Awesome expalinations!

  • @tijilparmar5758
    @tijilparmar5758 Рік тому

    Really nicely explained

  • @thetruthsayer8347
    @thetruthsayer8347 2 роки тому

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

  • @user-wi2sw6nw3s
    @user-wi2sw6nw3s 6 місяців тому

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

  • @jaydeeppawar1720
    @jaydeeppawar1720 2 роки тому

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

  • @ShivaKaalaCreations
    @ShivaKaalaCreations Рік тому

    Sir really it's very helpful, thanks.