Algorithms: Merge Sort

Поділитися
Вставка
  • Опубліковано 2 лис 2024

КОМЕНТАРІ • 249

  • @alix003
    @alix003 4 роки тому +44

    This was great! Thought I'd add a note that helped me understand the algorithm better. This is a recursion problem, and in the video, we end the recursion when the "left end" is greater than the "right start." That's all well and good, but at a conceptual level, it's still a little unclear what the base case of the recursion is. To answer this question, consider that just before the "left end" is greater than the "right start" (i.e. in the second to last recursion), we are calling mergesort on a single-element array. But a single-element array is, by definition, already sorted! So basically we recurse until the solution is trivial ("this array is already sorted because it only has one element"), and then we start to combine all of our single-element arrays back into a larger, still-sorted array using mergeHalves.

  • @adelinghanayem2369
    @adelinghanayem2369 5 років тому +233

    If you know merge sort and just want to refresh your knowledge this video is perfect otherwise ... It is bad for newcomers

    • @schoudhury3463
      @schoudhury3463 3 роки тому +3

      That's what I was thinking just typing away copy and copy that's all I hear

    • @jibuchackon
      @jibuchackon 3 роки тому

      Agree

    • @notanonymous3976
      @notanonymous3976 3 роки тому +1

      @Kaison Tony You're quite a trashy boyfriend and nobody cares.

    • @aydinatasoy8179
      @aydinatasoy8179 3 роки тому +2

      @@notanonymous3976 you wanna see something cool? if you click on Amari Jefferson's channel and Kaison Tony's channel you can see that they both joined youtube on april 23, 2021... this clearly means that these are fake comments made by the same person to make you believe that this InstaPlekt bullshit is real lmao

    • @techdan7098
      @techdan7098 2 роки тому +3

      I been coding for a long time and this video confuses the hell out of me.

  • @rcgldr
    @rcgldr 6 років тому +23

    This video shows top down merge sort. Note that merging does not begin until recursion reaches a point where two runs with a size of 1 element each is reached. Although top down merge sort is popular in educational environments, almost all implementations of merge sort used in libraries are variations of bottom up merge sort. For a basic bottom up merge sort, the repeated recursion used to divide an array is skipped and an array of n elements is considered to be n sorted runs of 1 element each , and the merging begins immediately, using iteration to maintain the indexes (or pointers) for the merge sort, as opposed to top down merge sort which has to push / pop indexes to / from the stack.

  • @rubenalejandro7763
    @rubenalejandro7763 2 роки тому +5

    Merge sort worked out example:
    Unsorted array
    [8, 2, 7, 4, 9, 5, 6, 3]
    Sort left half
    [8, 2, 7, 4]
    [8, 2] [7, 4]
    [8] [2] [7] [4]
    [2, 8] [4, 7]
    [2, 4, 7, 8]
    Sort right half
    [9, 5, 6, 3]
    [9, 5] [6, 3]
    [9] [5] [6] [3]
    [5, 9] [3, 6]
    [3, 5, 6, 9]
    Merge the two halves
    [2, 4, 7, 8] [3, 5, 6, 9]
    [2, 3, 4, 5, 6, 7, 8, 9]
    The algorithm is very straight forward, implementation on the other hand could get a little tricky just remember that in order to sort the halves you'll need to call merge sort recursively on each half.

  • @CuriousKaviCruiser
    @CuriousKaviCruiser 3 роки тому +23

    For some reason, most of the algorithmic videos from HackerRank team are more confusing than helpful.

  • @DyslexicAnaboko
    @DyslexicAnaboko 6 років тому +40

    I think it would be more helpful to the viewer to point out to them that the actual sort itself happens in the merge method. I found this incredibly confusing as the mergesort method doesn't actually sort anything it is just the recursive driver breaking down the array into smaller parts.

    • @abufaya4155
      @abufaya4155 2 роки тому +2

      Thanks bro been confused for hours wondering why the mergesort doesn't sort anything!!

  • @KhayamGondal
    @KhayamGondal 5 років тому +10

    Why not just use varible named start and end instread of leftStart and rightEnd? These makes it sound more complex.

  • @ferociousfeind8538
    @ferociousfeind8538 7 років тому +297

    ...why don't we just Magic Sort the whole list???

    • @atioar2214
      @atioar2214 7 років тому +16

      Lol

    • @gavriel6089
      @gavriel6089 7 років тому +7

      I think that in this specific simple problem we could just sort the whole list in one step, but in a more complex problem we would have to use Merge Sort Algorithm in order to solve the problem efficiently, as the whole purpose of Merge Sort is to break down the problem into two or more sub-problems until these are simple enough to solve directly.

    • @ylioo
      @ylioo 7 років тому +8

      dude its just fuking copy, the recrusion part was the real problem and she showed it to us. I hightly doubt that people came here cause they had a problem with copying the array ....

    • @ciphertester1147
      @ciphertester1147 6 років тому +2

      Jonas Grandt, she is just showing how merge-sort works towards the end she states that you'll never actually have to do this; other than C every other language as a nice library for search/sort and common data structures you can use.

    • @qwarlockz8017
      @qwarlockz8017 6 років тому +17

      Except you still get these in interviews

  • @nishchintdhawan848
    @nishchintdhawan848 6 років тому +16

    You don't need extra variables like left or right. You could just use leftStart and rightStart in the while loop. This made it a bit confusing as the code was already long enough.

  • @Rdharini
    @Rdharini 4 роки тому +2

    If you are a newbie to mergesort please come later - learn its basics and practice first. If you still couldnt get the code working after many hours of practice, come and watch this video. Its beautifully explained. Only after watching this, i can turn my pseudo code into working code. Thanks Gayle!

  • @danrussell_official
    @danrussell_official 5 років тому +105

    I'm a senior engineer, and I didn't even understand this video's explanation of merge sort

    • @ishaanpatel8374
      @ishaanpatel8374 4 роки тому +2

      This just shows how bad the video was!

    • @PoulJulle-wb9iu
      @PoulJulle-wb9iu 4 роки тому +8

      why even watching if u a senior bra..

    • @whiskeyburns5230
      @whiskeyburns5230 4 роки тому

      Even i was thinking that i can write a code to work without sorting rather than sorting this way,with equal to less effort

    • @DungNguyen-qy3yz
      @DungNguyen-qy3yz 4 роки тому +2

      Then you are not so a senior engineer? Joking, I don't understand either. Haha

    • @Sk8erMorris
      @Sk8erMorris 4 роки тому +2

      @@PoulJulle-wb9iu cause we learn this in senior year bruh bruh

  • @harshshastri6099
    @harshshastri6099 4 роки тому +3

    The only thing she's done different from the typical code for merge sort you'll find online is: she's used a temp array rather than removing elements from the two partitioned array and at the end checking which one's empty

  • @forforma
    @forforma 7 років тому +40

    Thanks for the explanation - sounds good but its' because I know it. But if I didn't I'd get it better if I've seen a break-down of the recursion on the pictures to see that divide& conquer gets these 'halves' to some small sizes in the end.
    I think also that you could have written the loop instead of using the System. method.. (and you could still mention that the library could be used). Why there are '+1' in 'size' and copy of the rest ?

  • @JeanYvesLimantour
    @JeanYvesLimantour 4 роки тому

    I'm surprised about the quantity of comments complaining about the video. It is great!

    • @schoudhury3463
      @schoudhury3463 3 роки тому

      No it's not

    • @JeanYvesLimantour
      @JeanYvesLimantour 3 роки тому

      @@schoudhury3463 ,have you considered other profession instead of coding? :)

    • @schoudhury3463
      @schoudhury3463 3 роки тому +1

      @@JeanYvesLimantour like what playing guitar in ur dark basement oh look at me I'm a coding genius but I'm watching basic merge sort algorithm...get da fuk outta here

  • @omarch.9202
    @omarch.9202 6 років тому +259

    I can't follow your explaination

    • @DyslexicAnaboko
      @DyslexicAnaboko 6 років тому +20

      +1 I feel that the variable names being used were a poor choice. Plus I can see in her book the code is different. I took the code from this example, wrote it down and now I am analyzing it while running it - but this explanation I felt was rushed and didn't explain much of anything.

    • @quirkyquester
      @quirkyquester 4 роки тому +1

      did you land a job in the end bro?

    • @schoudhury3463
      @schoudhury3463 3 роки тому +1

      @@DyslexicAnaboko I don't know why they do this if you're explaining something take extra minute which will help people understand the whole point of making the video smhhh

    • @DyslexicAnaboko
      @DyslexicAnaboko 3 роки тому +1

      @@quirkyquester ha, sorry I didn't see this until now. Thanks for asking. No I did not and here is what I have to say about it. I interviewed twice, they botched my first interview (long story) and they asked me to interview again, so I did. I am unimpressed with how they conducted the interview process because everything hinges on you coding something in google docs while somehow simultaneously explaining what you are doing to the "interviewer". My first interviewer sounded like she didn't want to be conducting the interview and I am pretty sure that's a contribution to why it was botched and I interviewed again. At least they acknowledged that. You have 45 minutes to implement a crapshoot choice complexity of an algorithm. If you don't complete it in 45 minutes your interview is over. The irony is, I completed the code in my first interview under 45 minutes, the second question I could not complete in 45 minutes. As a test I did it again outside of the interview using the same rules and I was only able to do it in one hour and fifteen minutes. So in my opinion an interview like this is pointless (I have conducted well over 50 interviews myself) because they have taken all of my experience and expertise and tied it to an arbitrary coding exercise and put it in the dumpster because I couldn't finish it in under 45 minutes. I was told I was eligible to interview again in 9 months, I told my recruiter I would not interview with them again because this was a miserable experience and I don't like their interview process.
      Unless they change how they conduct their interviews and conduct a REAL interview I wouldn't bother with them again. I don't think what they are doing is really testing anything because in the real world I would never come up with a 45 minute or less solution and give it to anyone as a finished product. I think I would be a good fit there because I spoke to several Google engineers in person and after gauging their reactions and responses to the things I was saying I can tell the environment would be perfect for me. Their loss not mine. I like my current job and I am already an Architect with a possibility of becoming a director in the future. My thing is though, I don't want to be a manager, I just want to code and a place like Google facilitates that. That's the only reason I even cared to bother with the interview(s) because I didn't reach out to them, they reached out to me.

    • @quirkyquester
      @quirkyquester 3 роки тому +1

      @@DyslexicAnaboko good job bro! I'm not planning to shoot for the FANG any more. The interview just isn't worth it. Thank you for sharing your experience!! Best of luck for you!

  • @AlexHope_SE
    @AlexHope_SE 5 років тому +57

    You can find better explanation of merge sort... She made it very terrible to understand for newbies... Before watching this read wiki and look other materials (if you are newbie as me) after that it will become more clearer.

  • @JPxKillz
    @JPxKillz 5 років тому +282

    Lol this isn't really an explanation, more of just. Hey, watch me code while I talk exactly what I'm typing.

    • @haliax8013
      @haliax8013 4 роки тому +10

      I completely agree. Being a good coder doesn't mean you are also a great teacher. Teaching complex and sophisticated subjects as sophistically isn't hard. What really hard is teaching it as minimal and understandable manner that anyone, literally anyone can understand.

    • @nullbrain8552
      @nullbrain8552 4 роки тому +25

      She isn't teaching code if you do not know code you should learn a language before trying to learn about algorithms such as this. She is teaching algorithm through coding I could totally see how easily you could confuse the two but if you do not know a language this video is completely useless to you. I suggest learning a language before trying to learn how to implement recursive algorithms.

    • @jotsinghchawla
      @jotsinghchawla 4 роки тому

      TRUE

    • @alansaldivares
      @alansaldivares 4 роки тому +2

      That's Gayle's style though. I usually watch her videos to get the possible solution, and then I jump to see the full detailed explanation from other sources.

    • @matt-g-recovers
      @matt-g-recovers 4 роки тому

      @@alansaldivares Exactly and how awesome that we have both as a resource for free!
      I love the conceptual high level CS videos but the best way to solidify a concept for me is to both learn it's theory and then code it and get it to work on a real problem. She could have done some things to make this is a little cleaner also, however, maybe the abstract algorithm calls for specific void return type on the methods? IDK... I think overall it's a good explanation. I was able to take this and 'Kotlinize' it...and well it compiles so far just doesn't sort the array lol!! It will here shortly, I am close ...got it, I had an issue with the copy over portion :) Anyway good video and great point Alan!

  • @johnson554671
    @johnson554671 3 роки тому +4

    First of all, the presenter is amazingly smart to write this code from scratch if not already scripted!
    Second, it is reinsuring to hear the part at 9:31 that in the real world it is not likely necessary to write sorting algorithms like this. Heap Sort seems to be the most fun to write.

  • @choogiesaur
    @choogiesaur 6 років тому +17

    pls redo this vid with better conceptual explanation/clearer code! :) (like you had in quicksort vid)

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

    This is definitely a great way to teach mergesort.

  • @jiggyg123
    @jiggyg123 5 років тому +3

    Really comprehensive- thanks! Have some big interviews coming up and trying to make sure I'm covered on all fronts.

    • @markuscwatson
      @markuscwatson 4 роки тому +1

      How did they go?

    • @jiggyg123
      @jiggyg123 4 роки тому +3

      @@markuscwatson I'm a software developer now so at least one of them went well!

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

      ​@@jiggyg123 congratulation!

  • @Manu-wb2uv
    @Manu-wb2uv 5 років тому +3

    I don't know how but I always end up to understand your approach. You have a very good coding style, design. Thanks a lot. I honestly learned all the data structures through your videos. I can't thank you enough!

  • @dadasajad8741
    @dadasajad8741 6 років тому +4

    I couldn't get it, may be I lack in my programming skills. But I really liked the explanation and, programming knowledge and efficiency of the lady. Amazing!

    • @qwarlockz8017
      @qwarlockz8017 6 років тому

      Just look for a different explanation. There are so many ways to explain things . You will find one that makes it click.

    • @dadasajad8741
      @dadasajad8741 6 років тому +1

      qwarlock Z I will sir. Thanks.

    • @qwarlockz8017
      @qwarlockz8017 6 років тому

      ua-cam.com/video/vCAbbJgMsQk/v-deo.html
      Look at this one. It is much easier when you can watch the movement of the alog on a board. The basics is there are only three lines doing the work. She splits the array in half. So one lone takes the left half, one line takes the right half. then it sorts them and merges them. but because of recursion... it keeps splitting until there are LOTS of arrays but only of size 2. now it tests and swaps if it needs to. Then it starts merging them up and resorting. merge up resort.. up this tree. If it FAST because when it does its first merge it is only merging two little arrays of size two that are already sorted.. there are just a lot of them. then it just moves up the tree. That is how all the recursions work. Put off doing the work untill we have recursively split the problem into tiny units that can be done fast. Then put them back together.
      Hers is hard to see because she did not show in the explanation very much of how it worked. Also, hers is REALLY fast because she did a REALLY clever optimization that speeds it up but totally confuses the explanation. Her code in here is GREAT. It just sort of requires you already know how it works.

    • @qwarlockz8017
      @qwarlockz8017 6 років тому

      ua-cam.com/video/4VqmGXwpLqc/v-deo.html

  • @torreyMama
    @torreyMama 4 роки тому +1

    Question: How is it that you "run the code" and it gives the output of a sorted array? you have no return values anywhere...? Im either blind or missing something here. The temp array needs to be returned somehow, but Im just not seeing it here.

  • @amroshIdreesh
    @amroshIdreesh 5 років тому +1

    I don't know what the comments are talking about .. I never knew merge sort before and I understood her explanation perfectly

  • @zaidsserubogo261
    @zaidsserubogo261 5 років тому +1

    Integer factorisation(mistaken as merge sort) is all about the polynomial merger hierarchy of quick sort.

  • @thechristoutreachproject
    @thechristoutreachproject 4 роки тому

    By dividing the list of numbers to right half and left half gave me the impression of divide and conquer, i feel like it would have been best if the analogy of sorting cards at hand was used.

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

    I don't get how anyone can think these things up in the first place, it's so counterintuitive. I need a new career

  • @handle-f5h
    @handle-f5h 2 роки тому +1

    Funny how Gayle seemed to have had a JavaScript moment around 3:40

  • @KhayamGondal
    @KhayamGondal 5 років тому +9

    I don't know how she makes simple things sound so complex and hard to understand.

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

    Do technical interviews at FAANG companies in 2022 ever actually expect candidates to write mergeSort()? I'm fine with having it in my toolbox, just seems like something I'd never ever actually need not even in a coding interview. I'll assume I really actually will need it and obsess over it anyway.
    In a modern Java whiteboard problem, am I likely to be fine by just using Arrays.sort(myArray)? I guess not if the entire point of the question was to show I know the algorithm. Well, I'll quite my complaining and keep on studying it.

  • @AK09037
    @AK09037 4 роки тому

    I don't agree with rest of the comments. The way she names her variables are amazing... I have been trying to understand mergesort for hours and this finally allowed me to get it!

  • @christorok1906
    @christorok1906 6 років тому +13

    I believe the concepts can be broken down better. I think mycodeschool does that. Gale's solution does work. But it is up to the learner to make a significant attempt to understand it. She's very similar to one of my CS professors who worked in industry. She moves quickly. Luckily there is a pause and rewind button. It is REALLY important for those of use to visualize this somehow. But once you learn it, it's hard to unlearn it as long as you visit it every once in awhile.
    It's also very important to at least attempt your own solution as well. There seems to be 100 ways to code something, but your mind only comes up with one.

    • @saturnzoom
      @saturnzoom 6 років тому +2

      This video is part of a series called Cracking The Coding Interview. A person who is learning merge sort for the first time is not the target audience.

  • @TheDEMMX
    @TheDEMMX 3 роки тому

    if you do (left+right)/2 it may potentially cause overflow, which will be a negative point in the real interview. The correct way is left + (right - left)/2. boo....

  • @labreynth
    @labreynth 3 роки тому

    This was terrible. I don't get the part with the if (leftStart >= rightEnd), what does that mean?

  • @BlueCheckThanos
    @BlueCheckThanos 3 роки тому

    Every single coding tutorial ever has 10x as many words as needed. Reeeeeeee

  • @raniketram
    @raniketram 3 роки тому

    Very helpful, thank you so much for this video.

  • @shufflingutube
    @shufflingutube 4 роки тому

    See this is why I find pretty stupid asking people for algorithms and data structures during an interview. There is no way someone can come up with this solution out of the blue unless you have memorized the implementation of the merge sort. Yes you would have memorized this and other implementations. These are things that are already solved! I know it is important for candidates to be aware of performance and memory but that would be enough! If the candidates have a portfolio where they clearly demonstrate caring about performance and memory, that would be freaking enough!

  • @moonhan2157
    @moonhan2157 3 роки тому

    It's vert clear, thank you!

  • @honeypot11
    @honeypot11 3 роки тому

    side note but your keyboard is so satisfying should make an ASMR channel LOL (no but rly what keyboard is that)

  • @0x656e
    @0x656e 4 роки тому +2

    array.sort()

  • @mengyichen3264
    @mengyichen3264 6 років тому +1

    may i know why the size should be plus 1 at the end of rightEnd-left start?

    • @faizquraishi6129
      @faizquraishi6129 5 років тому

      1 2 3 4 5 6 7 8 9 10
      Size 10
      To calculate size using an expression
      Last index (10 in this case) - first index(1 in this case)+1
      Which is
      10 - 1 + 1 = 10
      Similarly
      0 1 2 3 4 5 6 7 8 9
      Size 10
      To calculate size using an expression
      Last index (9 in this case) - first index(0 in this case) + 1
      Which is
      9 - 0 + 1 = 10

  • @shirins589
    @shirins589 6 років тому

    but when teacher said write steps which one is steps I mean how much of the numbers will be steps ? teacher give us some numbers and said just write the steps I mean this .

  • @saqibsaleem7633
    @saqibsaleem7633 6 років тому +7

    AGH!!! can't stand it anymore! I am giving you thumbs down! sorry

  • @kevinviricel4970
    @kevinviricel4970 7 років тому +7

    Shouldn't we calculate the middle as : leftStart + (rightEnd - leftStart)/2 to avoid overflow as mentioned in BinarySearch video ?

    • @tedthebed7877
      @tedthebed7877 7 років тому +1

      Same question here.

    • @bitti1975
      @bitti1975 6 років тому

      And I still prefer (rightEnd + leftStart) >>> 1

  • @ajishgoku875
    @ajishgoku875 7 років тому +18

    can't you just pass middle to mergeHalves rather than calculating it in both mergesort and mergeHalves ?

    • @Metallian2112
      @Metallian2112 6 років тому +3

      While yes, you could, its poor API design. Imagine the mergeHalves was being used by something that didn't calculate the middle point (like a unit test). You'd then be forcing the client to work out what the middle point is.

    • @DyslexicAnaboko
      @DyslexicAnaboko 6 років тому

      I would argue that if the methods are private then passing the middle index is fine. The client would be calling the initial Sort() method, so there isn't an opportunity for confusion.

  • @surya-sharma
    @surya-sharma 6 років тому +2

    If you didn't understand this, head to this video ua-cam.com/video/4VqmGXwpLqc/v-deo.html for an explanation, then come back here.
    I think this would've been easier if the merge was explained in concept rather than in code.

  • @yamannashawati7524
    @yamannashawati7524 3 роки тому

    I'm running the same exact code in it's giving me "ArrayIndexOutOf BoundsException". where did we go wrong!?
    public class mergeSort {
    public static void mergesort(int[] array) {
    mergesort(array, new int[array.length],0,array.length-1);
    }

    public static void mergesort(int[] array,int[] temp, int leftStart, int rightEnd) {
    if(leftStart < rightEnd) {


    int middle= leftStart + (rightEnd - leftStart)/2;
    mergesort(array, temp, leftStart, middle);
    mergesort(array, temp, middle+1, rightEnd);
    mergeHalves(array, temp, leftStart, rightEnd);
    }
    }
    public static void mergeHalves (int[] array, int[] temp, int leftStart, int rightEnd) {
    int leftEnd=(rightEnd+ leftStart)/2;
    int rightStart = leftEnd +1;
    int size= rightEnd -leftStart +1;

    int left= leftStart;
    int right = rightStart;
    int index = leftStart;

    while(left

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

      second to last line is the out of bounds. should read array.length -1, however you must have figured it out by now :D

  • @Play-Date-Care
    @Play-Date-Care 6 років тому

    public class MergeSort {
    public void sort(int[] arr) {
    mergeSort(arr, 0, arr.length-1, new int[arr.length]);
    }
    private void mergeSort(int[] arr, int left, int right, int[] temp) {
    if(left>=right) return;
    int middle = (left+right)/2;
    mergeSort(arr, left, middle, temp);
    mergeSort(arr, middle+1, right, temp);
    merge(arr, left, right, temp);
    }
    private void merge(int[] arr, int leftStart, int rightend, int[] temp) {
    int left = leftStart;
    int leftEnd = (leftStart+rightend)/2;
    int rightStart = leftEnd+1;
    int right = rightStart;
    int index=leftStart;
    int size = rightend-leftStart+1;
    while(left

  • @monkeytrollhunter
    @monkeytrollhunter 4 роки тому +1

    I'm here after Leetcode gave us a a problem to sort a linked list in ascending order

  • @sparsh-0384
    @sparsh-0384 3 роки тому

    Which editor it is ?

  • @zombieslayamr
    @zombieslayamr 5 років тому

    My problem is that she goes through the material as if she's in a rush. She could've simply shown a non-coding way of doing a merge sort rather than spending 2/3 of the video coding the sort. Giving people the answer doesn't help them understand the concept. If you give people the pseduocode and help them understand what a Merge sort is actually doing, then they can go an implement that in code themselves.

  • @mohammad-karbalaee
    @mohammad-karbalaee 3 роки тому

    this code has a flaw. on the 44th line change size to size + 1

  • @HugoAyala1983
    @HugoAyala1983 4 роки тому

    I think it's better to read the book and other sources first and then watch this video...I also advise watching it at 0.75 since she speaks really fast

  • @sangmanna1777
    @sangmanna1777 4 роки тому

    I like this clean code! Simple and easy to understand.

  • @atifadib
    @atifadib 4 роки тому +1

    Timsort: Hold my beer

  • @chrisdigiuseppe7717
    @chrisdigiuseppe7717 4 роки тому +1

    idk what you guys are complaining about, this wasn't that hard to follow.

  • @matt-g-recovers
    @matt-g-recovers 4 роки тому

    I have to say I owe you an apology Gayle. I resented you for what the hiring industry has become, due to the HackerRank association... As if you started the ranking of developers in one completely odd discipline thus barring the door for us older cats who don't remember this stuff from college lol...I just kept thinking "Why should we waste so much time memorizing this crap? Isn't it enough to know they exist if we need them for a solution?"
    Well I was wrong...just in the last couple of weeks I dove headfirst down the rabbit hole(as is my thing) this time with Algorithms and a whole new world just smacked me in the face.
    I still resent the hiring practice. HackerRank should be about competitive programming not people's livelihoods, that being said, EVERY developer should learn and code up the foundational algorithms, learn time complexity and the by-product of these algorithms we call data structures. I knew about the main ones and what they did, thinking that was enough...10 years a developer without a rich study of this stuff...why??? I could have been great:(... lol j/k can still be! Sorry Gayle and thank you

  • @pylog7386
    @pylog7386 4 роки тому

    I am not experienced enough to understand this. All i came here was for the first 20 seconds of the video

  • @tyefinenyu875
    @tyefinenyu875 3 роки тому

    Applying this to an algorithm I’m wanting to make

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

    overload method should not be used here as it cause confusion

  • @intothelonelystreets
    @intothelonelystreets 5 років тому +4

    It is difficult to understand her words. She speaks too fast for a tutorial video.

  • @Maturion
    @Maturion 7 років тому

    Thanks for the Video! Watched it right bevor an exam and it really helped!

  • @adrianjason13
    @adrianjason13 3 роки тому +4

    Man Gayle's algo tutorials are so bad it just confuses the heck out of me even more.

  • @baibhavghimire3827
    @baibhavghimire3827 6 років тому +4

    This is how u explain if you memorize the whole code..

  • @afz902k
    @afz902k 4 роки тому +1

    0:01 Hi I'm Gayle LaakMcDowel -- did you skip a syllable there?

  • @easward
    @easward 4 роки тому +1

    Very nice! This made me clearer.

  • @parsaparsa3367
    @parsaparsa3367 4 роки тому

    Why can't middle be defined as: (array.length)/2??

    • @prateekshiremath10
      @prateekshiremath10 4 роки тому

      A single array is being used for the whole sorting exercise here. For example, if the original array size is 8, after the first partition, the right half would have 4 elements and the left half would have 4.The length of the array is still 8 but the partitioned halves have 4 elements each and finding the middle element can only be done based on left and right indices for that sub array. Since this is recursive, the sub-arrays will go up to 1 element(base case).

  • @rhidlor8577
    @rhidlor8577 4 роки тому

    Please choose better variable names.

  • @randomdeveloper6456
    @randomdeveloper6456 6 років тому +3

    I didn't like your explanation..

  • @tylerhansen4566
    @tylerhansen4566 4 роки тому

    Does this code not work for anyone else?

  • @attsopal
    @attsopal 6 років тому +1

    very confusing.. cant keep up with her explanation ..

  • @s.sharich9719
    @s.sharich9719 7 років тому +3

    Ha. Lines 13, 14. When Left more then right. If not we done! O nooooo.

  • @Rajjj7853
    @Rajjj7853 7 років тому

    Why there are a lot of books back there with 4 kinds of language? The Chinese one is about interview lol.

    • @adwaitT
      @adwaitT 3 роки тому

      all the books are about interview

  • @mounirboussetta
    @mounirboussetta 4 роки тому

    This is not the obvious way to explain or code the merge sort, a lot of extra stuff for nothing :(

  • @nishantverma6466
    @nishantverma6466 6 років тому

    Why do people usually prefer Java for such topics?

    • @zombieslayamr
      @zombieslayamr 5 років тому

      Java is usually the language that is used to teach these topics in a University environment. You'll usually learn these in a data structures class, and they use Java because it is an easy language to teach a lot of the core elements behind Object-Oriented programming which can also be heavily used in implementing sorts and data structures.

    • @Yagamilight19383
      @Yagamilight19383 5 років тому

      It isn't bro. Different websites/universities use different languages or pseudocodes.

  • @haroonafridi1802
    @haroonafridi1802 6 років тому +2

    so many variables declarations.

    • @schoudhury3463
      @schoudhury3463 3 роки тому

      She's just trying to show off hey look at me I know how to code

  • @qwarlockz8017
    @qwarlockz8017 5 років тому

    I still have no idea why she does not fix this. It is obviously really explained badly. Had she taken her time and did a standard merge sort and then optimized it this would have been great. But in its current form it is really useless.

  • @bombrman1994
    @bombrman1994 3 роки тому +1

    this is exactly how every teacher or professor teaches at our garbage overpriced education when my cousin or friend can sit down and teach this shit in 10 minutes all together

  • @quirkyquester
    @quirkyquester 4 роки тому

    Thank you!

  • @mochamadhadyonosandi2085
    @mochamadhadyonosandi2085 4 роки тому

    What IDE u use??

  • @opeyemijonah8530
    @opeyemijonah8530 4 роки тому

    I thought I was alone not understanding the steps.

  • @haroonafridi1802
    @haroonafridi1802 6 років тому

    many variables declarations in the code = fragile code

  • @cactodagod9236
    @cactodagod9236 7 років тому

    What's the use of temp here

  • @saqibsaleem7633
    @saqibsaleem7633 6 років тому

    You, quite often, combine more than 3 words together while explaining and rush through them. What is that about?

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

    there a lot of things remain unclear after watching this video.
    i would except a detailed explanations from a channel this size and from a company in the domain of teaching.
    the implemenation is also very confusing and could be written in more simplfied way.
    waste of 10 mins to be honset.

  • @yevgeniyv.87
    @yevgeniyv.87 6 років тому +1

    Explanation is not good at all.

  • @JeffHall117
    @JeffHall117 7 років тому +12

    I'm really mad you just used arraycopy. Seems like a cop out and takes away from the lesson.

    • @ronborneo1975
      @ronborneo1975 7 років тому +11

      Copying is the easy part. Barely takes away from the lesson.
      while(left

    • @bitti1975
      @bitti1975 6 років тому +5

      No it adds to the lesson, because it shows you should use the methods which are supposed for the purpose (and in case of array copy its preferable because it's way more optimized than hand writing a loop).

    • @himani8927
      @himani8927 6 років тому +2

      smh, you should know how to copy. teaching hw to copy arrays wasn’t the point of this video.

  • @andrewcbuensalida
    @andrewcbuensalida 4 роки тому

    you should use a picture while coding

  • @smartmathimatics7599
    @smartmathimatics7599 6 років тому +1

    Anyone send me video toturial about Edit Distance in DP ?

  • @michaeleast4617
    @michaeleast4617 6 років тому

    ok, I'll buy your book.

  • @ManishSharma-ys5ws
    @ManishSharma-ys5ws 4 роки тому

    Thankyou so much !!
    You explained with such a simplicity....❤️

  • @pavelerokhin1512
    @pavelerokhin1512 4 роки тому

    lovely!

  • @chakidan
    @chakidan 7 років тому +1

    Does this Actually work?

    • @campermortey
      @campermortey 7 років тому

      Charaka Danansooriya not for me. Tried copying and pasting with no luck. Even found her information online with no luck

    • @ronborneo1975
      @ronborneo1975 7 років тому

      Yes, it does. Although, I did find it a bit strange how she doesn't explicitly split the list into two parts before merging. However it still works the same way with int[] temp.

    • @david52875
      @david52875 6 років тому

      no

    • @sergiotorres2742
      @sergiotorres2742 6 років тому

      it does works, here is the code github.com/oscargarza356/CodingProblems/blob/master/Solutions/MergeSort.java

  • @0x656e
    @0x656e 4 роки тому

    Why Java is so scary?

  • @Jonathan-od5xc
    @Jonathan-od5xc 5 років тому

    Splendid! Thank you.

  • @chunheilee6340
    @chunheilee6340 6 років тому

    okay I think this is for advanced programmer :P

  • @leomonz
    @leomonz 4 роки тому +3

    oh god, this mess my mind up so bad.......

  • @therealestnoah
    @therealestnoah 6 років тому

    This is too complicated to be considered a video on the "basics"

  • @user-qc9rq3vb2z
    @user-qc9rq3vb2z 5 років тому +2

    Okay J.K Rowling