Dark

Algorithms: Merge Sort

HackerRank
Subscribe
Views 346 441
75% 1 802 582

Learn the basics of merge sort. This video is a part of HackerRank's Cracking The Coding Interview Tutorial with Gayle Laakmann McDowell.
www.hackerrank.com/domains/tutorials/cracking-the-coding-interview?

Science & Technology

Published on

 

Sep 27, 2016

Share:

Link:

Download:

Loading link...

Add to:

My playlist
Watch later
Comments 148
Christian Reyes
Christian Reyes 6 days ago
The worst video on a comp. sci. algorithm I've ever seen.
Tyler Hansen
Tyler Hansen 10 days ago
Does this code not work for anyone else?
maximilliaan 04
maximilliaan 04 10 days ago
your voice is so annoying and the video is not helping it is showing
ND718 01
ND718 01 11 days ago
i mean you just read out loud what you were writing, its not really an explanation.
Zifu Song
Zifu Song Month ago
wow, I DONT follow
Suprise Nkosi
Suprise Nkosi Month ago
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.
Julio Gonzalez
Julio Gonzalez 2 months ago
Thanks!
*Frnkn shw
*Frnkn shw 2 months ago
0:01 Hi I'm Gayle LaakMcDowel -- did you skip a syllable there?
qwarlock Z
qwarlock Z 3 months ago
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.
intothelonelystreets
It is difficult to understand her words. She speaks too fast for a tutorial video.
videoguy640
videoguy640 3 months ago
Not a great explanation if you've never heard of it. But great as a refresher! Which is probably hackerRank intends it to be
Dan Russell
Dan Russell 4 months ago
I'm a senior engineer, and I didn't even understand this video's explanation of merge sort
George Ghabro
George Ghabro 22 days ago
same situation here! do u have any good explanation vid?
Ishaan Patel
Ishaan Patel 22 days ago
This just shows how bad the video was!
Jacob Gersfeld
Jacob Gersfeld 4 months ago
Really comprehensive- thanks! Have some big interviews coming up and trying to make sure I'm covered on all fronts.
NimeniTv
NimeniTv 4 months ago
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!
Ramanathan K
Ramanathan K 4 months ago
she takes the prize for the worst teacher in the history of computer science!
somekid
somekid 4 months ago
Oh bru, calm the hell down. She has various other videos out there that are fine.
Khayam Gondal
Khayam Gondal 5 months ago
Why not just use varible named start and end instread of leftStart and rightEnd? These makes it sound more complex.
Khayam Gondal
Khayam Gondal 5 months ago
I don't know how she makes simple things sound so complex and hard to understand.
Jonathan Doster
Jonathan Doster 6 months ago
Splendid! Thank you.
Charles Maurice de Talleyrand-Périgord
Soothing keystrokes.
E
E 9 months ago
Okay J.K Rowling
Amr Idrees
Amr Idrees 9 months ago
I don't know what the comments are talking about .. I never knew merge sort before and I understood her explanation perfectly
The Gamegineers
The Gamegineers 9 months ago
when sortiing the two halves before merging, what is the best way to do it for large mix ups? a smaller merge sort? quick sort?
Dillon Smithson
Dillon Smithson 9 months ago
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.
Afnan Shakeel
Afnan Shakeel 10 months ago
make it simpler
JPxKillz
JPxKillz 10 months ago
Lol this isn't really an explanation, more of just. Hey, watch me code while I talk exactly what I'm typing.
Ali Faraz
Ali Faraz 10 months ago
fucking terrble
ZAID SSERUBOGO
ZAID SSERUBOGO 10 months ago
Integer factorisation(mistaken as merge sort) is all about the polynomial merger hierarchy of quick sort.
sunshinezz03
sunshinezz03 Year ago
Had it been a man explaining in this video, he would have not gotten so much flak from the viewers. Clearly, tells you what is wrong with the tech industry and why there are such less women in it. The number of misogynistic comments here are simply shocking.
Elhanan Elhanan
Please just take a breath before you complete your sentence, Please(:
Iskander Khabirov
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.
Alex Lazea
Alex Lazea Year ago
Good intention, bad output
RadioactivFly
RadioactivFly Year ago
You put curly braces on the same line as declarations. Blocked and reported.
Hentai Eyes
Hentai Eyes Year ago
This is why no one hires women
Adelin Ghanayem
If you know merge sort and just want to refresh your knowledge this video is perfect otherwise ... It is bad for newcomers
Eric SOM DUTT
Eric SOM DUTT Year ago
Fuck her american accent.. horrible voice
matthew arnold
Shit explanation.
Nishant Verma
Nishant Verma Year ago
Why do people usually prefer Java for such topics?
Pritish Mishra
Pritish Mishra 4 months ago
It isn't bro. Different websites/universities use different languages or pseudocodes.
Dillon Smithson
Dillon Smithson 9 months ago
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.
mrtrex01
mrtrex01 Year ago
She doesn’t break this down well enough. She rushed through it and made you feel stupid on purpose. Bad teacher. This is coming from a person who knows merge sort.
meow peow
meow peow 8 months ago
@Alessio Sangalli then it shouldnt have "Learn the basics of merge sort" in the description.
Alessio Sangalli
Alessio Sangalli 8 months ago
Yes this is intended for somebody that has already studied and now needs a quick refresh to go to an interview... Or did you think that hours of computer science college lessons could just be condensed in 9 minutes?
meow peow
meow peow 9 months ago
completely agree, same thing with every her lesson... at least her book "cracking coding interview" are not that bad
Sergio Torres
Sergio Torres Year ago
Hi, if anybody needs the source code here it is feel free to use it. github.com/oscargarza356/CodingProblems/blob/master/Solutions/MergeSort.java
Mar A
Mar A Year ago
This is why nobody reads books anymore. If only her teaching ability was as big as her ear.
Vengeanze
Vengeanze Year ago
I am sharing my code because i feel like it is cleaner and doesn't use System.arraycopy package com.company; import java.util.Arrays; public class Main { static public void mergeSort ( int[] arr){ mergeSort(arr, new int[arr.length],0, arr.length); } static public void mergeSort ( int[] arr, int[] temp, int start, int end){ // [start, end) int length = end - start; if ( length > 1){ int middle = (start+end) /2; mergeSort(arr, temp,start, middle); mergeSort(arr, temp,middle, end); mergeArrays(arr, temp, start, end); } } static public void mergeArrays(int[] arr, int[] temp, int start, int end){ for ( int i = start; i < end; i++){ temp[i] = arr[i]; } int middle = (start+end)/2; int index1 = start; int index2 = middle; for ( int i = start; i < end; i++){ if ( index2 == end || (index1 < middle && temp[index1] < temp[index2])){ arr[i] = temp[index1]; index1++; } else{ arr[i] = temp[index2]; index2++; } } } public static void main(String[] args) { // write your code here int[] arr = { 10, 2, 5, 7, 4, 9, 12, 1, 8, 6, 11, 3}; mergeSort(arr); System.out.println(Arrays.toString(arr)); } }
Dylan Maulucci
What are those arrows for import??
Shirin S
Shirin S Year ago
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 .
Saqib Saleem
Saqib Saleem Year ago
AGH!!! can't stand it anymore! I am giving you thumbs down! sorry
Saqib Saleem
Saqib Saleem Year ago
My God! thats annoying!!!
Saqib Saleem
Saqib Saleem Year ago
You, quite often, combine more than 3 words together while explaining and rush through them. What is that about?
DIVVELA SRINIVASA RAO
hi friends please subscribe my you tube channel name: DIVVELA SRINIVASA RAO for videos on DAA(Design and Analysis of Algorithms)
Jin Izzraeel
Jin Izzraeel Year ago
arraycopy? Really?
rcgldr
rcgldr Year ago
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.
TECHFORCE
TECHFORCE Year ago
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
endale
endale Year ago
This is too complicated to be considered a video on the "basics"
DyslexicAnaboko
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.
Michael East
Michael East Year ago
ok, I'll buy your book.
zhi gao Keng
zhi gao Keng Year ago
Very good!
choogiesaur
choogiesaur Year ago
pls redo this vid with better conceptual explanation/clearer code! :) (like you had in quicksort vid)
baibhav ghimire
This is how u explain if you memorize the whole code..
Suraj K
Suraj K 4 months ago
lol!
qwarlock Z
qwarlock Z Year ago
ruvid.net/video/video-TzeBrDU-JaY.html a nice other look at Merge Sort
Surya Sharma
Surya Sharma Year ago
If you didn't understand this, head to this video ruvid.net/video/video-4VqmGXwpLqc.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.
Sam Parsons
Sam Parsons Year ago
This is an ass explanation, everybody should pirate her book for shit like this.
Haroon Afridi
Haroon Afridi Year ago
many variables declarations in the code = fragile code
Next videos
Merge Sort
7:22
Views 35