Home » Algorithms: Merge Sort | Chia sẻ về chủ đề merge sort |

Algorithms: Merge Sort | Chia sẻ về chủ đề merge sort |

Có phải là bạn đang muốn tìm kiếm nội dung nói về merge sort có phải không? Phải chăng bạn đang muốn tìm chủ đề Algorithms: Merge Sort đúng không? Nếu đúng như vậy thì mời bạn xem nó ngay tại đây.

Algorithms: Merge Sort | Xem thông tin về laptop tại đây.

[button color=”primary” size=”medium” link=”#” icon=”” target=”false” nofollow=”false”]XEM VIDEO BÊN DƯỚI[/button]

Ngoài xem những thông tin về laptop mới cập nhật này bạn có thể xem thêm nhiều nội dung hữu dụng khác do soyncanvas.vn cung cấp tại đây nha.

Kiến thức liên quan đến chuyên mục merge sort.

Tìm hiểu những điều cơ bản về sắp xếp hợp nhất. Video này là một phần của Hướng dẫn Phỏng vấn Cracking The Coding của HackerRank với Gayle Laakmann McDowell.

Hình ảnh liên quan đếnchủ đề Algorithms: Merge Sort.

Algorithms: Merge Sort

Algorithms: Merge Sort

>> Ngoài xem đề tài này bạn có thể xem thêm nhiều Kiến thức hay khác tại đây: Xem thêm nhiều kiến thức mới tại đây.

Nội dung liên quan đến đề tài merge sort.

#Algorithms #Merge #Sort.

[vid_tags].

Algorithms: Merge Sort.

merge sort.

Mong rằng những Kiến thức về chủ đề merge sort này sẽ có ích cho bạn. Cảm ơn bạn rất nhiều.

47 thoughts on “Algorithms: Merge Sort | Chia sẻ về chủ đề merge sort |”

  1. We are all now dumber for having listened to your explanation. Seriously though… how can you be so inept at explaining something so simple.

  2. 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

  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….

  4. public int[] mergeSort(int[] arr) {
    return mergeSort(arr1, arr.lenght);
    }

    private int[] mergeSort(int arr[], int len) {
    if(len == 1) return new int[] {arr[0]};

    int midIndex = len/2;

    int arr1[] = new int[midIndex];
    int arr2[] = new int[arr.length-midIndex];

    int i=0, j=0;

    while(i<arr1.length)
    arr1[i] = arr[i++];
    while(j<arr2.length)
    arr2[j++] = arr[i++];

    arr1 = mergeSort(arr1, arr1.length);
    arr2 = mergeSort(arr2, arr2.length);

    return merge(arr1, arr2);
    }

    private int[] merge(int arr1[], int arr2[]) {
    int res[] = new int[arr1.length+arr2.length];

    int i=0, j=0, k=0;

    while(i<arr1.length && j<arr2.length)
    if(arr1[i] < arr2[j])
    res[k++] = arr1[i++];
    else
    res[k++] = arr2[j++];

    while(i<arr1.length)
    res[k++] = arr1[i++];
    while(j<arr2.length)
    res[k++] = arr2[j++];

    return res;
    }

  5. 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

  6. There is a saying that you only truly understand something if you can explain it to someone else. This woman just memorized the code. She understands nothing and can’t explain shit.

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

  8. 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!

  9. 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.

  10. 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

  11. 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

  12. 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!

Leave a Reply

Your email address will not be published. Required fields are marked *