Merge Sort | Code and Explanation | C++ Course - 19.1

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ย. 2024
  • Complete C++ Placement Course (Data Structures+Algorithm) : • C++ Full Course | C++...
    Telegram: t.me/apnikaksh...
    Instagram: / dhattarwalaman
    Notes of this Lecture:drive.google.c...

ความคิดเห็น • 416

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

    accha explanation tha bs thoda code dry run kr k batate tho zyada accha hota

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

      Kahe ka acha kuch samaj ni aata 😢

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

      ​@@akshaykumar192 😅😅😅😅

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

    It is difficult topic but this lecture of 15 minutes make it easier and make program just in 10 minutes. Thanks Apna College Team and Aman bhaiya.

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

      is this course for beginner.....

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

      @@turbo4free631 NO BIG NO

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

    Code is giving undesired output if array elements are other than descending order.
    I have checked many testcases.

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

      bro after seeing your comment i realised the same mistake i made , maybe in int main you forgot to put mergesort(arr,0,length-1) and instead wrote mergesort(arr,0,length)

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

      @@vindhyakumar3434 then also It didn't work

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

    thanks to all who created this free of cost course

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

    instead of using 2 more while loops in merge( ) , u can simply just change the && with || , so..we do not need those extra while loops.

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

      I also thought so does it worked??

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

      No it won't work, might give a segmentation fault/ wrong answer as you are accessing element of an array outside its bounds.
      Suppose, i has reached n1 but j hasn't reached n2, by replacing "and" with "or" in while loop, you would still enter the loop, but this time you would be checking a[n1] with b[j], a[n1] might contain garbage value. Same case if j reaches n2 first, b[n2] contains garbage value.
      Hope this clears your doubt.

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

      no we can't do that because we would have 0 element in either array so we can't compare

  • @code-a-mania4100
    @code-a-mania4100 2 ปีที่แล้ว +1

    For Time comple. We get fractional part and n so it is simple it is logn*n

  • @vaibhav7453
    @vaibhav7453 4 หลายเดือนก่อน +1

    Take input from user

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

    fr i couldnt understand anything after didi stopped teaching😂🤣🤣🤣

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

    can anyone tell the problem that i faced in running the same code in the video
    my output is 5 2 5 5 5

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

    Bhaiya this code is working correctly only for the input (5,4,3,2,1) while we are changing this input then this code is not giving the correct output so please look into this matter. and please highlight this comment so that bhaiya can read this comment
    Thank you

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

      mera bhi output nahi aa raha hai

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

      Yes same problem anyone found solution so please help

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

      Bro which part sorts the arrays of size n1 and n2???

    • @irshadali-xx1ms
      @irshadali-xx1ms 3 ปีที่แล้ว +2

      #include
      #include
      using namespace std;
      void merge(int arr[],int l,int mid,int r)
      {
      int n1=mid-l+1;
      int n2=r-mid;
      int a[n1];
      int b[n2];

      for (int i = 0; i < n1; i++){
      a[i]=arr[l+i];
      }
      for ( int i = 0; i < n2; i++){
      b[i]=arr[mid+1+i];
      }
      int i=0;
      int j=0;
      int k=l;
      while (i

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

      @@irshadali-xx1ms thank you bhai 😀😀

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

    In the int main func when we write mergesort func then copy of arr should be sent .
    Then how does the sorted array got print by for loop not original array ???

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

    merge is done with only one extra array. it is not necessary to take 2 extra arrays and then merge.

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

      Yes ,by using two pointer

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

      we are using two arrays of size n1 and n2 that is n1+n2=n.
      so basically we are using O(n) extra space that is equal to one array of size n.

    • @MohammadKhan-ld1xt
      @MohammadKhan-ld1xt 3 ปีที่แล้ว

      how?

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

      @@MohammadKhan-ld1xt #include
      using namespace std;
      void merge(int a[],int s,int m,int e)
      {
      int temp[e-s+1];
      int p1=s;
      int p2=m+1;
      for (int i=0;im)
      {
      temp[i]=a[p2];
      p2++;
      }
      else if (p2>e)
      {
      temp[i]=a[p1];
      p1++;
      }
      else if (a[p1]>n;
      int arr[n];
      for (int i=0;i>arr[i];
      merge_sort(arr,0,n-1);
      for (int i=0;i

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

    her voice!!! too sweet!
    Great explanation!

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

    Awesome video, thanks for the easy explanation! :)

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

    What does( mid-l+1 ) mean how can I substrate l from mid

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

      As l always starts from 0. Suppose the value of Mid is 3 so "3-0+1" is equal to 4 which should be the size of first part of the array.

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

    Just another way to merge. We can take a single array of size n instead of 2 of n1 and n2. What we do is we divide the original array by marking them with the pointers i,j(not the * pointers xD). We merge and store them in the temp array and at the end we store the values in the original array.
    void merge1(int a[], int l, int mid, int h)// low, mid, high
    {
    int i=l, j=mid+1, k=0, n=h-l+1;
    int temp[n];
    while(i

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

      brother....can you explain me why the size of " n1=mid-l+1" array is taken? and in your problem also n=h-l+1?..please help I am confused

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

      ​@@adityagupta3870 ok let's say the array we take has size 10. While calling the function the value passed to low is 0 and the value passed to high is n-1(cuz if size 10 means from 0 to 9), i.e. 9 in this case. Now in the function, n denotes the size of our array(specifically size of the part of the array corresponding to the merge but here i will explain for the entire array cuz its easier to understand that way). So n needs to be 10. now low=0 and high=9, so high-low=9-0=9.
      So we add 1. High-low+1=9-0+1=10.

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

      @@sajankumarkar8237 damn bro!!!.. Thanks!!!... Can I have your id or something
      ... So that we can start with dsa together?

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

    thanks for this amazing playlist!

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

    Please upload web development course...🙏🏻🙏🏻

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

      @Nikunj Manhas thanks Nikunj 😂

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

    merge function is not only to to merge 2 arrays, its is also to sort and merge

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

      But in which portion is the sorting occuring???

    • @cswd428-yaswanth3
      @cswd428-yaswanth3 3 ปีที่แล้ว

      @@sohammukherjee_2193 in the merge fn

    • @UIEC_MANESH_RAM-tb1hb
      @UIEC_MANESH_RAM-tb1hb 2 ปีที่แล้ว

      your absolutely right and maybe didi missed it

    • @AmanKumar-nb4oh
      @AmanKumar-nb4oh 2 ปีที่แล้ว

      Yeah u can say like that while merging we sort them first

  • @AbdUllah-m2j3j
    @AbdUllah-m2j3j 7 หลายเดือนก่อน

    Only one of you can teach me correctly so proud you

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

    🔥🔥🔥Verithanam🔥🔥🔥

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

    Isn't the L pointer going to be zero and in what case it will be non zero?

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

    It's special for me because it is on Apna College Video.....first time ever😇1 comment, 1st like😄

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

      th-cam.com/video/2k7pS9wWPTI/w-d-xo.html

  • @AG-kw1rb
    @AG-kw1rb 3 ปีที่แล้ว +30

    Bhaiya Please upload the NOTES OF LECTURE 31 - Strings in c++

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

      Its 13

    • @AG-kw1rb
      @AG-kw1rb 3 ปีที่แล้ว

      @@aadityasharma6855 Its Lecture 31

    • @AG-kw1rb
      @AG-kw1rb 3 ปีที่แล้ว

      @@saimadhumita2144 yeah

    • @AG-kw1rb
      @AG-kw1rb 3 ปีที่แล้ว +1

      Thank you Aman Bhaiya and Apna College team as now the Notes of Stings in C++ are uploaded

  • @pankaj.yadav1
    @pankaj.yadav1 3 ปีที่แล้ว

    Ma'am bhut axa smjhati h

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

    explanation is just so clear

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

    Mergesort() function seems bit odd for me, since there is no returning statement🤔. I think it should return 0 at end

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

      its a void function bro

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

      well yes but actually no !! Firstly mergesort is a void function so it should not return anything but let's say if it wasn't a void function and something happened in the function but it doesn't return anything,in that case, no one knows for sure what will happen. The program may or may not run i.e it can result in a crash so to avoid that situation we always have return statements even after giving a return in a conditional statement inside a function.

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

      ps: I am not sure if the above claim made by me is totally correct and maybe there is good logic behind it, suggestions will be appreciated.

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

      there are two ways in which a function frame can be destroyed, either if return statement is encountered or if nothing is left in function.
      Try to think with a stack diagram. Hope it will help.

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

      @@praveenawesome2182 definitely u r correct i encounter many time no output wthout return statement bt after return statement program gives correct output

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

    Sir notes of this lecture??

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

    Documentation of our program is very important thing because it reminds us the logic behind program make sure everyone will write reason after each code using commenting

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

      ji sir jaisa aap kahen😶

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

    For those who are having doubt in line of code where: n1 = mid-l+1;
    see initially we have given l = 0, r = 7 in the array of length 8.
    then we will get mid = (l+r)/2 as (7+0)/2 = 3;
    so n1 = mid - l +1; will be 3 - 0 + 1 = 4;

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

      If you guys have any doubt you can reply to this comment.

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

      Here, mid is pointer and n1 is length from 0 to 3 (0,1,2,3)

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

    Why do u not get errors, even if u declare size of arrays as variables at runtime

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

      varies from compiler to compiler

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

      you need to declare and take input the variable, which you use as the size of the array, while declaring the array.

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

      THEY SKIP TO THE PART WHEN CODE IS RIGHT YOU CAN SEE IT FOR YOURSELF
      EXAMPLE THE VEDI THEY TYPE "mergeSort(arr,0,4);" BUT AFTER EXECUTION WHEN YOU CAREFULLY LOOK IT IS SUPPOSED TO BE " mergeSort(arr,0,5);"

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

    In the Merge function, why did we initialize k with L and not 0

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

    Can we get backtracking part 2?

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

    Amazing👍😍🤩

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

    Don't we have to take dynamic temp array in merge function. Why didn't you get errors?

    • @VishalGupta-oh7mb
      @VishalGupta-oh7mb ปีที่แล้ว

      space complexity ne allow kr dia On ko isl;ie

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

    very good explanation .
    I really enjoyed.

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

    output is coming wrong what's the problem behind it.
    #include
    using namespace std;
    void merger(int a[],int l,int r ,int mid){
    int n1=mid-l+1;
    int n2=r-mid;
    int b[n1];
    int c[n2];
    for(int i=0;i

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

    Love u didi 😘 bdiya pdhaya

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

    Backtracking ke baad toh kuch samajh nhi aa raha!! What to do??
    Ek baar poora course dekhlu aur uske baad phirse dekh lunga..... Yaa fir abhi poora concept clear karte huye chalu?

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

      Bhai clear krta chal abhi se wrna pura dekhne tkk itna frustrate ho jaega ki kr nhi paega🤐

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

    expecting better explanation for time complexity

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

    Only legends know video length is 17:10 ,before the video premiere

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

    Int n1 = mid - l + 1
    Didi ne 8:24 par (mid - l )mein 1 kyo plus Kiya hai agar kisi Ko iska reason pta hai toh pls jrur btana

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

    Best explaination Of Logic And TimeComplexity

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

    I have copied same code word by word but My code isn't running 😒

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

      same here bro wont know what the problem is

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

    Kyo karna hai merge sort jab hum pehle hi Selection Sort, Bubble Sort aur Insertion Sort padh chuke hai ????

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

      Due to time Complexity. Most efficient sorting technique as compared to others.

  • @virendraverma5855
    @virendraverma5855 9 หลายเดือนก่อน +1

    Function Mergesort how it working samajh nahi aaya

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

    Thanks a lot for this video

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

    Excellent and clear explanation. Thank you.

  • @alpha183_i
    @alpha183_i 7 หลายเดือนก่อน

    Thank you mam

  • @khuramkhalid5396
    @khuramkhalid5396 9 หลายเดือนก่อน

    THANK YOU SO MUCH!!

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

    Didi iss lecture ke notes add kardo description box main .. Woh blank reh gaya hh

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

    Test Cases Not included--
    Code is Below--->
    void merge(int input[], int low, int mid, int high){

    int b[high-low+1];
    int l1=low,l2=mid+1,i=0;
    while(l1

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

    Thx for Desi explanation , Ghusenge ghusenge...

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

    in void merge(int arr[ ], int l, int mid, int r). You said in arr[ ] we are getting to small size SORTED array. 1st array from l to mid. And 2nd array from mid+1 to r. And you said now we will make two temporary arrays. then merge them. KINDLY SOMEONE HELP 🙏🙏🙏🙏
    But in the starting how this arr[ ] got SORTED small size arrays??

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

      we are using recursion here, merge() function will be called number of times for every separation after mergeSort() function, not only once. And two temporary arrays because we can't traverse and make changes in the same array at the same time.

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

    Thanks 🔥☺️

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

    why is it showing expression must have a constant value while declaring temp array? pls help somebody

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

    Sorry ur eplanation was right ,😙😙😙😙😙😅😅😅👍👍👍👌I was doing in the wrong way

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

    1no. Content 🔥

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

    aced it...!!❤

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

    Thank you so much sister for your informative speech.

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

    Sir, time complexity nahi samjh aai? Please elaborate, the procedure. Or please suggest some materials to practice from.

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

      Are voh keh raha hai ki humne pehele n length ki array ko divide kiya half mai toh hum abb left array ko sort karne ko humko t(n/2)time lagega some for the right half of that array jab hum dono side ko plus karenge tab yee ayega -->>>
      i.e.
      t(n) = t(n/2)+t(n/2) = 2t(n/2)
      but hum divide karne ke baad merge bhi kar rahe hai toh usko humko merge karne ko linear time lagega i.e 'n'
      toh final recurrence relartion atta hai ki
      t(n) = 2 t(n/2) + n ...eq1
      yee aaya hai for the first split jo humne kiya n ko n/2 mai but hum mergeSort mai we divide the input list of length n in half successively until there are
      n lists of size 1.
      so, if humko left or right half of the array ke liye recurrence relation chahiye toh follow same procedure but iss baar n half hai.
      replace n by n/2 in the eq 1

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

      @@sachinbairi6353 thnx bro

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

      @@sachinbairi6353 tumne toh bade acche se samjhaya bro

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

    When God come to help poor students ❤️

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

    CAN ANYONE PLEASE EXPLAIN WHAT IS THE ERROR IN THIS CODE:
    #include
    using namespace std;
    void merge(int arr[],int l,int mid,int r){
    int n1= mid-l+1;
    int n2= r-mid;

    //temp arrays
    int a[n1];
    int b[n2];
    //array ke elements ko 2 temp arrays mein bhar rhe hai
    for (int i = 0; i < n1; i++)
    {
    a[i]=arr[l+i];
    }
    for (int i = 0; i < n2; i++)
    {
    a[i]=arr[mid+1+i];

    }
    //checing when putting the values backing in the k array
    int i=0;
    int j=0;
    int k=l;
    while(i

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

      In merge function the second for loop should be b[i]=arr[mid+1+i] instead of a[i]

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

    i have copied same code but my array is not sorting please help

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

    like bubble sort

  • @ManmohanBhardwaj-ft2hu
    @ManmohanBhardwaj-ft2hu 11 หลายเดือนก่อน

    Program is not working it show error in running in online gdb c++ compiler

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

    I got the code, but why did she use 'l' and 'r' ??

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

    I didn't understand the time complexity part

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

    Great explanation maam, it's clear all of my doubts

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

    Ma'am mergeSort sahe work nhe kar rahr hy mana bhut bhar check kiya hy liken program main kohe error nhe hy liken arr ko sorrt nhe kar raha hy

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

    output blank aaraha hai. Can anyone help please

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

    any better approach than this while using functions in recursive way??

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

    thanx a bunch

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

    Why is the size of temporary array (mid-L+1)

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

    will merge sort work for odd no. elment in an array?

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

    shukriya

  • @onimthestrongest6229
    @onimthestrongest6229 9 หลายเดือนก่อน

    Nice

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

    the array was not dynamic then how it got sorted in main function?
    plz someone explain

  • @nothing-ce6rs
    @nothing-ce6rs 3 ปีที่แล้ว +1

    Mam u r keep saying pointer..
    Is that pointer or index?
    Bcz pointer should have Asterix(*) sign

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

      Aree Bro Pointer Doesn't Only Means That U have To Take a * Sign , Pointer also Means To Pointing something

    • @nothing-ce6rs
      @nothing-ce6rs 3 ปีที่แล้ว

      @@harshitrathi3077 acha

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

    Roses are red,
    Violets are blue,
    The title is in English,
    So the VIDEO SHOULD BE TOO

  • @hemant-li1gp
    @hemant-li1gp ปีที่แล้ว

    in mergeSort function we pass arr of main function by value, then how did this changed the array in main function

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

    Thanks didi for good explanation with less time.

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

    Thanks

  • @harshsharma4670
    @harshsharma4670 11 หลายเดือนก่อน

    I am having segmentation fault while running this code can anyone help??

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

    getting output only when I give input as same you have given but whenever I change my input array sequence or give a sorted array as input code is not working

  • @shauryaraghav7281
    @shauryaraghav7281 3 หลายเดือนก่อน

    ye voice switch itni funny thi lol

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

    It is important for us not gonna lie but this is hard.
    If it wasn't this important most of us would've skipped this right???

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

    I have copied same code , but it's not running, frustrated af 😑

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

    NOTES PLEASE

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

    Suggestion: please use comments to explain what the variables are

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

    ye th even number of elements pe kaam ni kr rha hai...

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

    in the next while loop, i replaced the while loop with for loop and it was not showing correct results but I don't understand y

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

    Why initializing k as 0 not giving the right answer?
    Help please

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

      Because k is the iterator for arr[] array which starts from l and end at r.

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

    how merge function return value as it above declared with void data type

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

      In case of array , whatever changes are made in the array are inflicted in the original array itself that is arr[], we need not return anything. Changes are made in the original array only.

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

    classic video!!!!!

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

    I will like apna college only when it will rectify the isssue.

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

    my time complexity is coming out O(n log(2n))

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

    Amazing

  • @user-ld3ny2yp2y
    @user-ld3ny2yp2y 2 ปีที่แล้ว

    Please put hindi in the description or smtn, I got really confused by the intro lmao

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

    This code is not working properly on gfg😑