Thank you sir :) Before starting this course/playlist I was really demotivated how will I manage DSA! But now I'm a bit confident in this topic :) Thank you again sir...
Dinesh - One question - In the merge method, why was the first array exhausted (low to mid) and second array (mid+1 to high) remaining not considered? I did not get that.
Because initially in the merge method we are copying the elements from arr to temp. In arr elements are sorted from low to mid and mid+1 to high, so while merging we are again traversing low to mid with the help of i variable and mid+1 to high with the help of j variable in the temp array and comparing temp[i] & temp[j] whichever is less we are filling them into arr and incrementing So when left sub array got exhausted and right sub array go remained means all the elements remained in the right subarray are greater than the elements of left sub array and some elements of right subarray, but if we observe they are already present to the end of the arr array so we need not again copy them even if we copy them again we will get the same result. But it is not the case of the left subarray elements if it remained means initially those values are at near mid of arr and got replaced while merging and these leftover values in the left subarray must be filled at the end of the 'arr' array with the help of while loop which sir have given as they are already sorted.
Hi Dinesh, as we are not using the temp array for sorting method, it is just used for merging, what is the use of sending it in the sort method input parameter?
Sir you are a great teacher. I am learning data structure from your videos❤🙏
Thanks !!! I would request you to share it with ur friends and colleagues.
Thank you sir :) Before starting this course/playlist I was really demotivated how will I manage DSA! But now I'm a bit confident in this topic :) Thank you again sir...
Welcome !!
Thanks sir i can easily understandable your vedios thanks sir this is great tutorial to learn datastructures thanks you sir
Welcome !!!
kya ap bata paynge or kitne videos banne baki hai..Matlab ki kitne topics abhi baki hai??
Its endless topic ... I will keep on updating the playlist ... So far most of the topics are there
Dinesh - One question - In the merge method, why was the first array exhausted (low to mid) and second array (mid+1 to high) remaining not considered? I did not get that.
Because initially in the merge method we are copying the elements from arr to temp. In arr elements are sorted from low to mid and mid+1 to high, so while merging we are again traversing low to mid with the help of i variable and mid+1 to high with the help of j variable in the temp array and comparing temp[i] & temp[j] whichever is less we are filling them into arr and incrementing So when left sub array got exhausted and right sub array go remained means all the elements remained in the right subarray are greater than the elements of left sub array and some elements of right subarray, but if we observe they are already present to the end of the arr array so we need not again copy them even if we copy them again we will get the same result. But it is not the case of the left subarray elements if it remained means initially those values are at near mid of arr and got replaced while merging and these leftover values in the left subarray must be filled at the end of the 'arr' array with the help of while loop which sir have given as they are already sorted.
Excellent
Thanks !!!
Hi Dinesh, as we are not using the temp array for sorting method, it is just used for merging, what is the use of sending it in the sort method input parameter?
you need to then add temp as instance level variable ... or else without sending to sort you can pass to merge !!!
Very nice
Thanks !!!
Thank you
Welcome !!!