Merge Sort Algorithm in Java - Full Tutorial with Source

  Рет қаралды 165,463

Coding with John

Coding with John

3 жыл бұрын

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

Пікірлер: 302
@metdelta1
@metdelta1 2 жыл бұрын
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 Жыл бұрын
Agreed, he explained it clearly and step by step, such a great explanation!!!
@akosdanielbollok4956
@akosdanielbollok4956 Жыл бұрын
This is pure gold! I wish you did a full Data structures&algorithms course, that would be awesome.
@nguyencongthaisonk14hcm57
@nguyencongthaisonk14hcm57 2 жыл бұрын
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 жыл бұрын
Thanks Vietnamese Guy! Very glad I was able to help!
@timjoyalle318
@timjoyalle318 2 жыл бұрын
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!
@cr8444
@cr8444 2 жыл бұрын
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!!
@moeal5110
@moeal5110 2 жыл бұрын
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
@akshaypatel9982
@akshaypatel9982 2 жыл бұрын
Wow, the first explanation that made complete sense with 0 confusion.Thank you very much! Wish you were my teacher back in college lol
@AceNinja1101
@AceNinja1101 2 жыл бұрын
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!
@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
@mir.9805
@mir.9805 Жыл бұрын
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.
@sekharsamanta6266
@sekharsamanta6266 7 ай бұрын
Hi Mr. John, I've seen so many videos on different algorithms of other people but your explanation is crystal clear and unique
@chrismendez1177
@chrismendez1177 2 жыл бұрын
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!!
@Nerdymelreads
@Nerdymelreads Жыл бұрын
You do not know how much I looked around for a better explanation. You nailed it. Earned a new subbie.
@LTZMSYAL
@LTZMSYAL Жыл бұрын
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 :)
@J-wm4ss
@J-wm4ss Жыл бұрын
Thanks! This makes SO MUCH MORE SENSE than other explanations!
@kosaken1207
@kosaken1207 2 жыл бұрын
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!
@HisExcellencyAKK
@HisExcellencyAKK 2 жыл бұрын
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).
@franklinoduro7274
@franklinoduro7274 2 жыл бұрын
Hands down this is the best sorting algorithm video i have seen on youtube. Thanks John
@BlueHat1
@BlueHat1 10 ай бұрын
This is the best explanation of merge sort I've ever heard. Thank you!!
@haidaralihammoud2686
@haidaralihammoud2686 5 ай бұрын
That is by far the best explanation out there! Amazing technique of teaching and breaking it down. Thanks a lot!
@elshaterhassansaber7644
@elshaterhassansaber7644 3 жыл бұрын
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 ....
@mahmoudmoussa6722
@mahmoudmoussa6722 2 жыл бұрын
For such comprehensive&best merge sort out there, you won a subscriber. Thanks.
@neurohan
@neurohan Жыл бұрын
You are, without a doubt, one of the most talented educators I've come across (both online and offline).
@raoulkid
@raoulkid 2 жыл бұрын
The only person on yt that actually explained the merge subroutine properly, thanks, +1 sub
@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.
@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 :) .
@Yersinia1988
@Yersinia1988 Жыл бұрын
I was so frustrated and sad about not understanding the merge sort. Your explnation is very clear, made my day. Thanks a lot! :)
@igor9919
@igor9919 2 ай бұрын
This is by far the best tutorial for merge sort, thanks so much
@AamirBilalm
@AamirBilalm 2 жыл бұрын
Great work John, really appreciate it. Highly undervalued channel. Hope you get the support you deserve.
@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.
@kevalkrishna4134
@kevalkrishna4134 Жыл бұрын
Such a calm and beautiful explanation for merge sort algo , loved it. And yeah ,you earned a new subscriber.
@sujanreddy9770
@sujanreddy9770 Жыл бұрын
Whenever I need to refer algorithms I will directly watch your videos thanks for explaining so clearly.
@rishijuvekar7572
@rishijuvekar7572 2 жыл бұрын
What an excellent explanation !! Simple, clear and concise. Thank you very much.
@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.
@rodrigosalomao3835
@rodrigosalomao3835 Жыл бұрын
I've finilly learned this. Thanks a lot dude!
@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.
@natnal9587
@natnal9587 10 ай бұрын
Honestly, this is the best video I have ever seen about merge sort.
@wasekasi
@wasekasi 2 жыл бұрын
This is by far the best sorting app I've seen someone code. Awesome.
@nosehad5486
@nosehad5486 Жыл бұрын
great, you are the only one that explained it in a way that i understand
@MrRobschke
@MrRobschke 2 жыл бұрын
This video is insanely well made!! Good job :)
@ayyanchira
@ayyanchira 17 күн бұрын
Really good explanation! Thanks John! Your videos are spot on!
@davidl6797
@davidl6797 16 күн бұрын
Great explanation John! It was easy to learn and understand this algorithm with your lesson!
@doncilaarcadie
@doncilaarcadie 2 жыл бұрын
Finally I got this!!! Thank you!!! The best explanation so far!!!
@ferhatf9385
@ferhatf9385 Жыл бұрын
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
@pelinegriboyun948
@pelinegriboyun948 2 жыл бұрын
awesome video! couldn't understand merge sort at all before this explanation, thank you so much
@HelicopterRidesForCommunists
@HelicopterRidesForCommunists 2 жыл бұрын
You are such a good teacher. Very talented at communicating information and concepts. 1 million sorted thanks to you.
@sagarrawal7740
@sagarrawal7740 Жыл бұрын
seriously one of the best merge sort explanation
@fakhrulmb
@fakhrulmb Жыл бұрын
Subscribed! Helped me through my Algo and data structure unit!! Best coding tutorial out here!!
@melissanicole4030
@melissanicole4030 Жыл бұрын
Thanks John! Very clear explanation
@michaellese3604
@michaellese3604 2 жыл бұрын
Great video, super easy to follow and made understanding merge sort way easier
@georgikyshenko4380
@georgikyshenko4380 Жыл бұрын
That explanation was AMAZING ! Thank you !
@trentlandon9033
@trentlandon9033 Жыл бұрын
You really made it look so easy and understandable
@tulioperez6011
@tulioperez6011 2 жыл бұрын
Amazing teaching skills - perfection execution
@Qongrat
@Qongrat Жыл бұрын
Loved every second of it!
@seyedaliroshan2386
@seyedaliroshan2386 Жыл бұрын
I liked the way u describe the stuff so clear and nice
@jeremiahnji6
@jeremiahnji6 Жыл бұрын
Super clean coding! Thank you
@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.
@lyn8964
@lyn8964 2 жыл бұрын
Your videos let me fall in love with java! So much Java fun!
@kishordige9721
@kishordige9721 Жыл бұрын
Best one, getting addicted to your videos!!!
@mariusandries4103
@mariusandries4103 2 жыл бұрын
Thank you, this explanation is so clear and short.
@mohammadahmedragab837
@mohammadahmedragab837 2 жыл бұрын
I love your easy amazing explanation of the code and the concept, thank you so much ❤️
@_Anna_Nass_
@_Anna_Nass_ Жыл бұрын
Thank you so much! This was super helpful for my assignment. I feel like I really understand now.
@taldennis8058
@taldennis8058 2 жыл бұрын
This video is something else, I watched all the big channels before I got here, this explanation is by far the most detailed and the most accurate, also providing an explanation for all the edge cases. the implementation is super clear and clean. this channel is underrated, I wish I knew this channel earlier. thank you so much, you're the best!!
@TuanBuianonymous
@TuanBuianonymous 2 жыл бұрын
agree
@pranusharavula2943
@pranusharavula2943 Жыл бұрын
Agreed yeah
@vikasjaiswal3247
@vikasjaiswal3247 2 жыл бұрын
Excellent explanation John
@wilsvenleong96
@wilsvenleong96 2 жыл бұрын
Definitely the best explanation out there. I'm subscribed.
@juanjaureguireyes
@juanjaureguireyes 2 жыл бұрын
Hi John! Thanks a lot for your video. Quite helpful for my C++ programming assignment. Cheers!
@user-xc9ne4oq3r
@user-xc9ne4oq3r 2 жыл бұрын
This is really great! you make it really easy. Thank you for your work!
@sk_4142
@sk_4142 8 ай бұрын
Professors at top CS programs like UC Berkeley (where I suffered) aren't able to explain this stuff as well and as clearly as you in multiple 2-hour-long lectures. From the bottom of my heart, I thank you for existing.
@willemvanderveen7567
@willemvanderveen7567 2 жыл бұрын
Keep it up man, your videos are absolutely amazing
@juanrada1940
@juanrada1940 2 жыл бұрын
Fantastic video! "If you want to be cool you can..." is priceless!
@user-pb6ps2mb4y
@user-pb6ps2mb4y Жыл бұрын
Awesome explanation! As usual!!! Thank you, John, so much!!!! You're the best!!😊
@celinareger2704
@celinareger2704 11 ай бұрын
I really like your explanation. I watch many other videos befor and as a biginner I understand nothing but your examples are really good and understandable. 😊 Also you're make it really interesting.
@cesar-on-youtube
@cesar-on-youtube Жыл бұрын
You're an excellent teacher. Thank you.
@sriplano748
@sriplano748 Жыл бұрын
Thanks John for a real good explanation of Merge Sort algorithm with code.
@EduardoFerreira6
@EduardoFerreira6 Жыл бұрын
Thanks, your explanation is very clear.
@AliBulut-tg6bh
@AliBulut-tg6bh 3 ай бұрын
We all have been taught that merge sort is a fast efficient but memory poor algorithm. But to actually see that happen really changes things. I think it was the first time I saw someone pushing the algorithm to its limit memory-wise. Thank you sir, it was a great explanation.
@Nicolasv67
@Nicolasv67 2 жыл бұрын
This really helped me. Many many thanks!!!
@studyingit9762
@studyingit9762 Жыл бұрын
Great video THANKS JOHN!!
@abhishekhm1264
@abhishekhm1264 Жыл бұрын
I cannot believe this channel exists. The way he explains!!!. Just Awesome!!.
@shriharshbankapur9666
@shriharshbankapur9666 2 жыл бұрын
Thank u john for putting it in my head! u got a lifetime subscriber.
@thetruthsayer8347
@thetruthsayer8347 2 жыл бұрын
I like this. I wish there more algorithm tutorials based in java. Please make more.
@yuselina8769
@yuselina8769 2 жыл бұрын
This video is amazing! Thank you for your explanation!!
@viveks1170
@viveks1170 7 ай бұрын
straight to my brain .thanks!
@renathanobre
@renathanobre 2 жыл бұрын
love this tutorial, thanks for the amazing explanation and for sharing it
@stacy623
@stacy623 2 жыл бұрын
This is really helpful! Thank you for your work!
@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!
@asmaasadek7735
@asmaasadek7735 2 жыл бұрын
Just wanted to tell you, you are one of the best!
@jeremy-hq9de
@jeremy-hq9de 4 ай бұрын
Helped alot, thanks!
@madhavansan008
@madhavansan008 2 жыл бұрын
You are born to teach ! , Expecting more and more videos
@grozageorge2887
@grozageorge2887 8 ай бұрын
Awesome exaplained and easy to understand 😇😊
@aliasghari8554
@aliasghari8554 Жыл бұрын
the best...this algorithm stuck in my mind hardly
@tijilparmar5758
@tijilparmar5758 Жыл бұрын
Really nicely explained
@InvinciRD
@InvinciRD 8 ай бұрын
I would be heavilyy grateful if make more vdos of such kind...y=you have the potential of conquering the market(by market i mean the hearts of students as your speech of explanation is crystal clear)
@dotherap
@dotherap Жыл бұрын
Amazing guide, thank you.
@dreivonfunf9489
@dreivonfunf9489 8 ай бұрын
Thank you for this great tutorial!
@makeitsimple4734
@makeitsimple4734 2 жыл бұрын
Thank you so much for the explanation. You’re a life saver 😄
@hawagiri4035
@hawagiri4035 4 ай бұрын
easiest explanation ever, keep up the good work.
@gokul_sankar7939
@gokul_sankar7939 Жыл бұрын
Really awesome john🎉!❤
@kushalmondal618
@kushalmondal618 2 жыл бұрын
With this Explanation any one can write Merge sort on their first Program , Subscribed quickly , Never gonna miss the chance to get better explanations of Hard topics, Like your work........💯🔥
Quicksort Sort Algorithm in Java - Full Tutorial With Source
24:58
Coding with John
Рет қаралды 227 М.
Bubble Sort Algorithm Tutorial in Java - How Fast Is It?
11:33
Coding with John
Рет қаралды 66 М.
маленький брат прыгает в бассейн
00:15
GL Show Russian
Рет қаралды 4,4 МЛН
Why Is Merge Sort O(n * log(n))? The Really Really Long Answer.
36:50
Back To Back SWE
Рет қаралды 112 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
Merge Sort In Python Explained (With Example And Code)
13:35
FelixTechTips
Рет қаралды 189 М.
Create a Sudoku Solver In Java In 20 Minutes - Full Tutorial
20:25
Coding with John
Рет қаралды 314 М.
Merge Sort Using Recursion (Theory + Complexity + Code)
49:47
Kunal Kushwaha
Рет қаралды 195 М.
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1 МЛН
Learn Merge Sort in 13 minutes 🔪
13:45
Bro Code
Рет қаралды 246 М.
Airpods’un Gizli Özelliği mi var?
0:14
Safak Novruz
Рет қаралды 6 МЛН
На iPhone можно фоткать даже ночью😳
0:30
GStore Mobile
Рет қаралды 1,4 МЛН
How Neuralink Works 🧠
0:28
Zack D. Films
Рет қаралды 30 МЛН
😱НОУТБУК СОСЕДКИ😱
0:30
OMG DEN
Рет қаралды 1,6 МЛН