Merge sort | Time and Space | Data Structure and Algorithms in JAVA

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ม.ค. 2025

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

  • @pratapjavasingh3239
    @pratapjavasingh3239 4 ปีที่แล้ว +14

    Most of the TH-camr upload the video sorting like bubbles selection insertion but when times comes in merged and heap they will not upload the video bcz they also not clarity about these two approaches merged and heap but in ur case sir speechless they way u explained no words ur teaching styles mind-blowing one day definitely more famous Gurudeva 🙏

  • @josteins4501
    @josteins4501 4 ปีที่แล้ว +12

    Sir you have taught recursion very well so well that now i find merge sort much easier to understand thanks sir

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว

      I am glad you understood it well. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )

    • @josteins4501
      @josteins4501 4 ปีที่แล้ว

      @@Pepcoding sure sir

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

      same here

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

    This is the simplest explanation for merge sort ..... Thank you, sir !! 🙏 🙏

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

      Happy to help

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

    Lots of respect for you.

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

    malik sahb koi ni h esa samjane wala love u brother

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

    first time understand many thing:) learning is never ending process . your video inspired me a lot to study more

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

    Sumit bhaiya Ekdum jeher padhate ho!!!!

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

    sir bahut jagah se merge sort padhe but finally ab jakr clear hua

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

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @vihaansingla5088
    @vihaansingla5088 4 ปีที่แล้ว

    Sir you clear all concept very beautifully . I like your videos and i love coding

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว

      If you like my efforts, I request a review
      g.page/Pepcoding/review?rc

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

    When u say "ye video dek k aao" please put it in annotation or link it. Also ty for your work!

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

      Hanji beta, will provide the link.
      Keep learning and keep loving Pepcoding😊

  • @rahul-sinha
    @rahul-sinha 3 ปีที่แล้ว +4

    Working CODE for me - without using 2 LHS, RHS array - using only one single temp array
    import java.util.Arrays;
    public class MergeSort {
    public static void main(String[] args) {
    int[] arr = { 8, 3, -2, 7, 5 };
    mergeSort(arr, 0, 4);
    System.out.println(Arrays.toString(arr));
    }
    public static void mergeSort(int[] arr, int start, int end) {

    if (start < end) {
    int mid = (start + end) / 2;
    mergeSort(arr, start, mid);
    mergeSort(arr, mid + 1, end);
    merge(arr, start, mid, end);
    }
    }
    public static void merge(int[] arr, int start, int mid, int end) {
    int i = start;
    int j = mid + 1;
    int k = start;
    int[] ans = new int[arr.length];
    while (i

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

    if(lo == hi)
    {
    return arr;
    } why cant I do this in base case?

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

    sir i can not understand how you made base case

  • @akhilkumarsingh5041
    @akhilkumarsingh5041 4 ปีที่แล้ว

    kafi ache se samkja diya apne

  • @ManishTiwari-ge1wc
    @ManishTiwari-ge1wc 4 ปีที่แล้ว

    Great Sirr ji

    • @Pepcoding
      @Pepcoding  4 ปีที่แล้ว

      Thankyou beta!
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

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

    base case samajh ni aaya. can anyone please explain?

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

      I'm also having problem. Is your concept clear by now?

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

    Sir ya euler vla video kha h

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

    Sir ye Euler graph kyu bolte hain isko? Where is the theory on it

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

    sir aap har cheez ko itna easy kaise bna dete ho

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

      Mehnat se Beta

  • @hiddentruths69
    @hiddentruths69 4 ปีที่แล้ว

    Thank you sir

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

      So nice of you!! share among you peers

    • @hiddentruths69
      @hiddentruths69 4 ปีที่แล้ว

      sure sir

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

    Why did we considered two halfs of array as fsh = (lo to mid) ssh = (mid+1 to hi) why not fsh = (lo to mid-1) ssh = (mid to hi)

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

      bcoz consider a situation where only 2 elements are there, so lo=0 and hi=1 and mid becomes 0+1/2=0 and when you do mid-1 it becomes -1 so you are saying that first function argument will be lo to mid-1 which means 0 to -1 , this doesn't make sense

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

    Fsh and ssh ka size to dikhya hi nhi hai sir