Merge sort algorithm

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.ค. 2013
  • See complete series on sorting algorithms here:
    • Sorting Algorithms
    In this lesson, we have explained merge sort algorithm. Merge sort is a divide and conquer algorithm that has worst case time complexity of O(nlogn).
    See source code of real implementation here -
    gist.github.com/mycodeschool/...
    For more such videos and updates, subscribe to our channel.
    You may also like us on facebook:
    / mycodeschool

ความคิดเห็น • 1.2K

  • @RahulGupta-vd2ns
    @RahulGupta-vd2ns 4 ปีที่แล้ว +1034

    *4 years back when I was in college I studied for my exams from this video. 2 years later I watched this video for my placements. Now I'm switching my job and I already know where to go for Sorting lectures. Still the best!*

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

      Great

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

      Hi

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

      Man we are on the same boat. Exactly the reason why I am here for the nth time. Mycodeschool is really my first and last school to excel.

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

      Sorry for asking. I am a beginner .
      is sorting that important that it takes these many years to master?

    • @RahulGupta-vd2ns
      @RahulGupta-vd2ns 3 ปีที่แล้ว +15

      @@cpwithsundar When you'll start using Arrays.sort or other lib functions eventually you'll forget how these work

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

    These videos are 7 year old , but still no body can touch the level of these videos. I watch so many tutorials but no-one provide such clarity. Bow down to you man. Really appreciate your work.

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

      Yep. There won't be a need for any others. The thing about a lot of branches of mathematics - once certain algorithms / properties are discovered, they won't change. Not for hundreds and thousands of years. Occasionally we find more efficient ways to prove / achieve the same results.

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

    One of the few accents of the world that I trust and feel safe with when it comes to learning CS

  • @AmanKUMAR-vq1ls
    @AmanKUMAR-vq1ls 3 ปีที่แล้ว +26

    I am studying this in April2021, still it's the best. No one can match this level, bahut bada change ho gya hota indians ka coding level agar Aaj bhi wo team work kr rhi hoti.. RIP Harsha,, u are immortal

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

      The Lord Harsha

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

      True brother I can't believe this playlist is actually 8 years old, still best on internet.

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

    This video is legendary, it's like an archive of all CS students coming here to learn after professors can't explain it well. From comments made 6 years ago to 5 months ago, no one leaves confused

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

      its low key sad but im grateful to those who make these videos

  • @haritar9053
    @haritar9053 7 ปีที่แล้ว +321

    18 minutes of complete understanding vs 24 hours of breaking my head. Thank you so much!

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

    Your lecture meant a lot to me. I was on the verge of quitting college and computer science for good because I don't understand anything my professor taught. I was ashamed and full of self doubt and I often beat myself up because I struggled so hard to understand recursive and algorithm but making absolutely no progress at all until I found your video. Your teaching gave me hope and is the reason why I'm still hanging in there. You're an inspiration so pls don't stop what you're doing, I won't forget what you'd done. Thank You!

  • @sovichettep
    @sovichettep 9 ปีที่แล้ว +74

    I've been through many videos of yours, and I can't stop telling my friends to come into your channel to watch. Your explaination is great. You explain the concept very well and, yeah, the visualization of each algorithm process is also easy to understand. :)

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

    I watch these videos instead of my professor's online lectures

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

    Just came to know that one of the the co-founder of this channel Harsha passed away few years back, may he rest in peace. Your videos have been helpful ever since college to this point.

    • @sohamhegde2386
      @sohamhegde2386 3 ปีที่แล้ว

      Any idea who are the other founders?

    • @vandankumbhat5391
      @vandankumbhat5391 3 ปีที่แล้ว

      @@sohamhegde2386Don't remember but you can google that. Seems the channel is still running.

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

    Out of the 3 techniques studied so far, this one, undoubtedly, stands the most elegant in all its form and execution. It's just beautiful to watch every little piece, in the end, fit itself in the right place automagically.

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

    This is hands down the best explanation of Merge Sort. No other video breaks it down the way you did. Thank you so much!

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

    Why youtube videos are greater and more helpful than school and university?
    tnx a lot dude

  • @natashagupta913
    @natashagupta913 10 ปีที่แล้ว +40

    Excellent videos! I have been trying to study for them for days and none of the other videos match the completeness of your videos..thank u so much for posting!

    • @mycodeschool
      @mycodeschool  10 ปีที่แล้ว +8

      Thanks Natasha Gupta :)

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

    My head was spinning when i tried to understand the merge sort by myself , thanks to your tutorial the logic of the algo is now pretty clear to me in a single instance.
    All the best,Keep up the good work

  • @tonyvumbaca2597
    @tonyvumbaca2597 7 ปีที่แล้ว

    Such a great job explaining this concept. This is the best walk through of the merge sort algorithm I have seen so far. Especially how you show the order in which the machine handles each step of the recursion process. Thanks for making this video!

  • @parikshit475
    @parikshit475 5 ปีที่แล้ว +21

    Wow, 100% perfection & clarity. U R The Best Indian coder.

  • @amareshkarnan7462
    @amareshkarnan7462 5 ปีที่แล้ว +5

    I was breaking my head for this merge sort and your explanation was perfect. Thank you Soo much. I watched twice and I implemented this on my own in JAVA the code is working great.

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

    These videos had a significant impact on my algorithmic thinking. I'm grateful that I found these videos in first semester of college 7 years ago.

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

    Thank for your great work, I have watched this long back and am still watching now to get refreshed on these topics. And your content gives that satisfaction of how nice it will be once you understand something. Thanks again.

  • @robomextv
    @robomextv 6 ปีที่แล้ว +44

    Pseudo code was awesome clearly explained

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

    i know a lot of people say that "hey you explain better than my professor", but for real merge sort was a nightmare since my class, but i could wrote the code myself with just your explanation. Thank you!

  • @himanshuinca
    @himanshuinca 5 ปีที่แล้ว

    I just love the way you have explained the whole concept, Easy ,fast, understandable and most important easy to code

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

    I always felt like the mergesort was daunting to implement so I never tried. And you have made it so easy to understand, cheers mate!

  • @PhucNguyen-gb7ul
    @PhucNguyen-gb7ul 4 ปีที่แล้ว +4

    Thanks a lot for your clarification about Merge Sort!!! It is super helpful. I used to not understand because recursion is a struggle for me. But now, I can understand better.

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

    I never comment on youtube, but this guy's explanation is phenomenal. Thank you sir

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

    You have immense talent in simplifying things ! Keep up the great job. Thanks a TON !

  • @caiozowyecamachocabral5413
    @caiozowyecamachocabral5413 6 ปีที่แล้ว

    My friend, i've been watching all kind of videos, about computer science, data structure, engeneering, etc, and I've never watched a so well-explained video this.

  • @TejaKarlapudi
    @TejaKarlapudi 5 ปีที่แล้ว +8

    Never thought Merge sort was this easy. I was able to code Merge Sort algorithm myself after watching this video! Thank you, pal!

    • @OmPrakash-sl4if
      @OmPrakash-sl4if 2 ปีที่แล้ว

      Brother ❤️❤️❤️Fan of Being techster❤️❤️❤️

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

    Genius, you helped me get a 10 at A&DS, I apreciate your work!!

  • @NadinMagdy
    @NadinMagdy 3 ปีที่แล้ว

    I keep coming to you videos every couple of years when I need them. Still the best!

  • @CseyCorpus
    @CseyCorpus 10 ปีที่แล้ว +49

    What a high quality teaching!!! With this type of instructor, if you don't get an A in the class, you must really be dumb. Keep the good teaching. I wish some of my instructors could explain things with this details. Really cool following your tutorial.

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

      Thanks a lot CseyCorpus

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

      I think the main issue is that instructors like to teach very formally, but it should be done informally first. Then formally. This is how it should be taught. :)

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

      I must be really dumb because I have never gotten an A in any of my courses at Uni. I am in my third year. 😂😂My best grade is A-...

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

      your dumb for thinking that examination can determine a persons intelligence.

  • @SpencerDavis2000
    @SpencerDavis2000 5 ปีที่แล้ว +6

    Yes I agree I am actually getting a clear understanding as well as gaining a new insight to recursion based on how you teach. You teach both from theoretical as well as programmatic (practical) and actually show what is going on in the stack which is really cool.
    Can you teach the Minimax algorithm for applications to something simple like Tic Tac Toe ?

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

    Well done! So hard to find folks that know technical subject matter well, while at the same time are able to communicate what they know well!

  • @jedng9639
    @jedng9639 3 ปีที่แล้ว

    8 years on and this is still the only video I need to watch to understand merge sort. Thank you sir!

  • @MrW3iss
    @MrW3iss 9 ปีที่แล้ว +529

    Great explanation, thorough and clear. You should consider teaching at university if you don't already! Better than most of my professors :p

    • @charlesz5949
      @charlesz5949 7 ปีที่แล้ว +10

      what year do they teach this in university? Im learning this in grade 12 right now

    • @MrW3iss
      @MrW3iss 7 ปีที่แล้ว +12

      I think freshman or sophomore?

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

      Ryan Weiss what are some stuff you learned in freshman? thanks

    • @MrW3iss
      @MrW3iss 7 ปีที่แล้ว +36

      Charles Z As a freshman they usually require you to take all beginner/common courses all various disciplines, then you start specializing your second year on when you declare a major and/or minor. First years of programming were basics of Java, how computers work, how programming works, all that stuff, very simple. Figure out what you want to learn, and then find a course that will be suitable. I taught myself most of what I know programming-wise early on, and didn't get much out of college, except some neat stuff like how to make your own languages, AI was kinda difficult, otherwise things we're fairly basic. Most of the stuff around CS when I was in college was a mix of theory and implementation, ie. sorting algorithms and graph traversals and all that kind of stuff, but they won't try to stick you with any specific technology, so they have to broaden their approaches to teaching, and for that reason it's tough to find a course that specialized skillsets can benefit from. Advanced CS courses can offer things like cryptography, AI, data mining, etc So just figure out what interests you, then how you can do it, and go for it. Lots to learn on the internet as well, but it's nice to be able to work it through with others if that's how you learn best. Best wishes.

    • @chaudharyadityakumar6149
      @chaudharyadityakumar6149 6 ปีที่แล้ว +19

      what if I tell u the guy teaching died in 2014 at very young age.

  • @md-ayaz
    @md-ayaz 8 ปีที่แล้ว +296

    You are making India proud.

    • @eosapril
      @eosapril 8 ปีที่แล้ว +7

      +Mohmmad Ayaz Shaikh i understand nothing from this India...

    • @adelECDW
      @adelECDW 8 ปีที่แล้ว +9

      Use closed captions on any youtube video you cant understand. Its the "CC" button in the bottom right corner of any video.

    • @xinli7477
      @xinli7477 6 ปีที่แล้ว +25

      @Eos April Seriously? English is not even my mother language and I understand fine.

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

      Eos April lol .. rip for uh then !! english lang. is not our mother lang. but still we indian can easily understand it either its american or UK english... nd uh people still remain as a dumb 😂

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

      I now click on the programming videos from India first.

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

    This is ridiculously the best explanation ever on the internet. I don't know if anyone who doesn't understands this will probably get an easier explanation anywhere. Thanks a lot dude. You explained the algo so well using pseudo code I could very well right my own code, in fact anyone should be able to.

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

    Prior to watching your video I knew how to implement a merge sort and regurgitate the underlying logic, but I didn't really own the knowledge. The first 12 minutes of your tutorial connected the few missing links in my logic chain that a lecture and several hours of reading couldn't. Thank you very much!

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

    The best explanation of merge sort recursion
    U really need to consider becoming a prof if not already.

  • @zichunyuan2732
    @zichunyuan2732 5 ปีที่แล้ว +6

    Amazing man!! Still watching in 2019!

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

    This was a great tutorial. Very clearly presented. The subtitles while not needed is a nice touch. Awesome job!!

  • @RafaelNascimento-qo1jp
    @RafaelNascimento-qo1jp 4 ปีที่แล้ว +1

    Fantastic! I was striving to understand that algorithm for a long time, now everything pretty is clear!
    You have the ability to turn complex things into simple things!

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

    Thank you for this bro! Explained perfectly!! Keep up on good work.

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

    Thank you very much. Your explanation is very clear! You're awesome dude!

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

    Its been 2021 but still cant find a better dsa series than mycodeschool !!

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

    OHHH MY GOD THANK YOU SO MUCH. I was struggling trying to figure it out myself. Explaining how the commands are processed helped a ton.

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

    Loved the way u explained

  • @kartaLaLa
    @kartaLaLa 8 ปีที่แล้ว +56

    thanks a lot, you save my lab homework , I stuck on this hard algorithm :)!!
    thank you very much.
    Department of Computer Science, National Chiao Tung University ,Taiwan

  • @miket4234
    @miket4234 4 ปีที่แล้ว

    woah .. im really amazed by this explanation of merge sort and the concept of recursion! one of the key things for me to keep on mind when thinkin abt recursions is for each level of recursion it goes into, think of the previous or upper level sublist/execution as “PAUSED”
    and then when it returns/exit the recursion and merges (left+right), it continues back executing the upper sublist’s right half

  • @mp0157
    @mp0157 5 ปีที่แล้ว

    Nicely articulated by breaking the algorithm down into sub-modules that helped make sense of the recursion. Thank you, this helped!

  • @sarajilani8088
    @sarajilani8088 10 ปีที่แล้ว +5

    Thanku soooo much.. U explained better than any textbook could have :)

  • @omkarbhise380
    @omkarbhise380 9 ปีที่แล้ว +5

    It's really better than reading big reference books

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

    Absolutely brilliantly explained! I cannot thank you enough. You should definitely do more Algorithm videos.

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

    This is Gold. This content will never die till Algorithms exists in this world.

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

    I have almost give up Computer Science / Programming. I was never a CS student, and I failed my first coding test when I was interviewing for a software engineering position. At that time, I didn't even know how a Linked List work.
    I think it's around 3 years ago, I found this channel. The videos here inspired me what programming foundation is all about. I come back to this channel from time to time to clear my concepts on DS&A.
    Today, I am a Data Scientist, and I am coming back again because I am having an interview from my dream company - one of the FANGs. I am sure that the content of this channel will help me to get through the interview.
    I really want to pay tribute to myCodeSchool, because it just democratise the knowledge of Computer Science. It also inspires the world that, as long as you have a good teacher, you can learn anything you want.

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

  • @JigarShah2811
    @JigarShah2811 7 ปีที่แล้ว

    mycodeschool is the best resource to visually understand DS algo. We are eagerly awaiting for more recent videos on new topics.

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

    Really by far the best videos. Clear, understandable and complete! Thank you for your effort.

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

    Sooo helpful. Thank you! :)

  • @vivekmishra007
    @vivekmishra007 7 ปีที่แล้ว +8

    RIP humblefool ( Harsha Suryanarayana) Thank you for everything .

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

      The tutor in the video is Animesh Nayan, Harsha's junior and Co-founder from MyCodeSchool.
      Read more at: yourstory.com/2014/06/techie-tuesdays-humblefool

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

    This is 9 year old video but it doesn't seem , the way he tell the concept so patiently and beautiful all doubt get eradicate and sense of understanding built with crystal clear logic .

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

    I don't know how to thank you guys.........you cannot imagine how useful your videos are for college students....keep up the good work and I shall be much obliged if you could include lessons on heap,radix,shell sort and other sorting algorithms as well.......Thank you once again

  • @satyajeetjha1681
    @satyajeetjha1681 7 ปีที่แล้ว +5

    u r a daddy programmer .excellent teaching skill .

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

    I need a love react in TH-cam especially for this video!!!🖤🖤🖤

  • @PrateekJesingh
    @PrateekJesingh 8 ปีที่แล้ว

    Thank you for such an amazing step by step explanation of the algorithm!!
    Very useful in actually visualizing the whole recursion process!

  • @sparrowthesissy2186
    @sparrowthesissy2186 8 ปีที่แล้ว

    Absolutely clear. I'll recommend this video to anyone looking to learn about merge sort. This makes it about as simple as it could be.

  • @mdalam-yy7gq
    @mdalam-yy7gq 10 ปีที่แล้ว +5

    First of all, this lecture help me to understand how divide and conquer works, then how merge sort actually works and why the time complexity of merge sort is nlogn. Finally, it also help me to gain the basic knowledge of recursion. God bless you.
    CS Student - Stony Brook University.

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

      Hi Alam,
      Glad that you found this lesson useful. Thanks for your wishes.

  • @MatejKripner
    @MatejKripner 8 ปีที่แล้ว +13

    "One of the halves will have more elements than the other half" :D Anyway, great video!

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

      I understood that video faster than this comment.

    • @eulucaspedroabreu
      @eulucaspedroabreu 3 ปีที่แล้ว

      Does true half exist outside of theoretical math? Infinitesimal numbers would argue.

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

    Videos uploaded in 2013. After 9 years still relevant. That's what quality content it. I wish you upload more videos on your channel

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

    You're better than my professor. I exhausted my brain with my professor's teaching, now I am not worried anymore. Thank you!

  • @dhirenlalwani9728
    @dhirenlalwani9728 6 ปีที่แล้ว +15

    /* C program for Merge Sort */
    #include
    #include
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
    int i, j, k;
    int n1 = m - l + 1;
    int n2 = r - m;
    /* create temp arrays */
    int L[n1], R[n2];
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
    L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
    R[j] = arr[m + 1+ j];
    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
    if (L[i]

  • @spacezombie99
    @spacezombie99 9 ปีที่แล้ว +7

    Dear #mycodeschool
    These video lectures are simply amazing. Thank you so much. I just have a question, in your implementation how are you free-ing the memory allocated for left and right arrays using malloc?

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

      Good catch vandana r ! The arrays should be freed. They are created using malloc, so they should be freed explicitly at end of the MergeSort function. Modified the code.

    • @Mitche23
      @Mitche23 9 ปีที่แล้ว

      mycodeschool It this was written .NET framework you wouldn't have to worry about memory allocation and dealocation

    • @somemathkid2889
      @somemathkid2889 6 ปีที่แล้ว

      yeah but also would cut ur market into a third

  • @bakanndy
    @bakanndy 6 ปีที่แล้ว

    Brilliant and detailed explanation of the algorithm. This is the best one I've seen so far.

  • @huizhao2050
    @huizhao2050 5 ปีที่แล้ว

    I have seen several MergeSort videos. This one is the best one to explain MergeSort algorithm.

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

    Great Video... I only have one doubt how will we determine the length n of array A in function MergeSort() in real C code? i tried running int n=(sizeof(A)/sizeof(A[0])) but its not working inside MergeSort()..i think we will have to give size n as parameter to MergeSort()....

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

      oh so sorry I didnt saw the github source code... many thanks for the source code...now i understood it's implementation clearly....

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

    The explanation in CLRS is really very lousy. Thank heavens you made this video.

  • @TheKrewboy101
    @TheKrewboy101 6 ปีที่แล้ว

    Great job explaining. You turned something complex into something anyone with basic programming skills could understand. Thanks!

  • @dev__adi
    @dev__adi 7 ปีที่แล้ว

    @mycodeschool , Thank You Man, I understood the concept of Merge Sort really well for the first time.Awesome Tutorial , loved it

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

    How can people dislike this video.....either they must be from some other planet or must be heavily drunk....

  • @Kovai-Siva
    @Kovai-Siva 10 ปีที่แล้ว +4

    Thanks for the video. Have a question,
    what will be the time complexity of merge sort for avg and best case? I think this is also O(n log n). Am i right?

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

    You're making my revision for a data structures & algorithms exam easy!

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

    Bro this video is awesome, thank you so much. 9 years later i spent all my morning on the internet trying to understand this until I found you!

  • @benjaminmiao3630
    @benjaminmiao3630 6 ปีที่แล้ว +38

    Your teaching efficiency is lg n, which I like very much. But our teacher’s teaching efficiency is 2^n...

    • @SV-zi9os
      @SV-zi9os 6 ปีที่แล้ว +29

      nigga du u understand that higher efficiency is better.

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

      @@SV-zi9os shut the fuck up moron

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

      Benjamin Nitro you troll urself man 😂😂

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

    Not all heroes wear capes...

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

    Thank you so much! This was really helpful. This is the first topic I got to where reading the book alone wasn't enough. I really appreciate the tutorial, thanks

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

    HANDS DOWN THE BEST CHANNEL FOR PROGRAMMING CONCEPTS!

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

    take a bow sir !!

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

      Thanks a lot Anurag :)

  • @mycodeschool
    @mycodeschool  10 ปีที่แล้ว +55

    See source code of real implementation here:
    gist.github.com/mycodeschool/9678029

    • @IndrajithIndraprastham
      @IndrajithIndraprastham 10 ปีที่แล้ว +10

      Really useful video. Keep posting videos like this. I am just wondering how you make videos like this? What are the software used to create these drawings? Are you using any pen device to write with this precession or your control with mouse is just excellent? Thank you

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

      Indrajith Indraprastham
      They have a blog entry about this. blog.mycodeschool.com/2013/11/how-to-create-amycodeschool-style-video.html

    • @veerendra.k
      @veerendra.k 8 ปีที่แล้ว +1

      mycodeschool
      Thanks for the nice explanation.
      In that
      At line numbers 20 and 21 in the above code. (you mentioned in that link)
      while(i < leftCount) A[k++] = L[i++];
      while(j < rightCount) A[k++] = R[j++];
      Instead of while loop, can we use "IF"? or is there any specific reason
      for "WHILE"?. Because, after exiting the main while loop(line no. 16),
      there should be 1 element left either in left array or right array.
      For example, if the condition in mail while loop fails, the control
      goes to 2nd or 3 rd while loop. In those loops, we are not checking any
      conditions, simply putting the remaining elements in main array.Then why
      we are using WHILE loop? I hope you understood what I'm saying or may
      be I misunderstood the algorithm. Thanks!

    • @sagarmitra4249
      @sagarmitra4249 8 ปีที่แล้ว

      i need source code without useing pointer

    • @cesarjom
      @cesarjom 8 ปีที่แล้ว

      +Veerendra Kakumanu - no, it is not correct to think that (for all cases) only 1 element will remain in L or R arrays, after first while() loop exits. Consider this example of merging the following arrays: L = {1,2} and R = {3,4}.

  • @limwenming
    @limwenming 10 ปีที่แล้ว

    Thank you! The last few minutes of the video were very helpful in helping me understand how a recursive algorithms flow. Thumbs up

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

    I have never used merge sort before. But after having watched your video I could write the code for it myself. With a little glancing at your pseudo code. Fantastic explanation, I'll have to have a look at your other videos.

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

    for average case we will use theta notation not the Big O notation.

    • @hasnainahmad6195
      @hasnainahmad6195 7 ปีที่แล้ว

      chup kr ja bhai. pata hay nae kuch bakwass kr rha h theeta ka bacha

    • @amandeepsaxena9579
      @amandeepsaxena9579 7 ปีที่แล้ว

      Ohh...tameez seekh le...gwaar...tb kuch seekhana..

    • @chanpreetsingh5054
      @chanpreetsingh5054 5 ปีที่แล้ว

      hahah lodhuuu
      @@amandeepsaxena9579

  • @reynoldyehezkiel
    @reynoldyehezkiel 5 ปีที่แล้ว +14

    2019?

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

    Genius idea making these videos widescreen. Can't wait to see this on IMAX

  • @aakashsaini8816
    @aakashsaini8816 5 ปีที่แล้ว

    I always used to mug up MergeSort and QuickSort. But thanks to you Sir, i am know able to understand every core concept of these algorithms. Thanks

  • @Rjsipad
    @Rjsipad 9 ปีที่แล้ว +7

    I like when he says swapping. It's pronounced swopping.... not swapping xD but great video

    • @rajgurujavalagaddi5133
      @rajgurujavalagaddi5133 6 ปีที่แล้ว +15

      this is not english class u idiot

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

      It's pronounced swäp so he is right.

    • @AbhishekKumar-lp5rc
      @AbhishekKumar-lp5rc 6 ปีที่แล้ว +2

      it's depends on your accent and what regional variations in the language.

  • @shlokisthebest
    @shlokisthebest 7 ปีที่แล้ว +20

    papa ko pranam _/\_.,, arey!!!

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

    This channel was way ahead of its time!

  • @b.n.wcreator8460
    @b.n.wcreator8460 3 ปีที่แล้ว

    I was pretty confused about the logic of merge sort until I stumbled upon your video, but now I am confused that why I was so confused about in the first place. The video is awesome. Thank you sir.

  • @human-011
    @human-011 5 ปีที่แล้ว +7

    anybody in watching in 2018

    • @RajK-nx8cf
      @RajK-nx8cf 5 ปีที่แล้ว

      even at 2118 also , this video (myCodeSchool) will stands outs of others