Sort K sorted array | Sort nearly sorted array

Поделиться
HTML-код
  • Опубликовано: 24 окт 2024

Комментарии • 35

  • @ashokjat555
    @ashokjat555 3 года назад +22

    Bro I wanna Thank you from the bottom of my heart, Finally I got my first job at Zoho with a decent package.Your videos were really helpful for my preparation and I'll remember you.Thank you!!!

    • @techdose4u
      @techdose4u  3 года назад +2

      Woww great ❤️Congratulations🎉 Happy to hear this 😀 I feel proud 😁 Wish you all the best for your job offer.

    • @ashokjat555
      @ashokjat555 3 года назад +2

      @@techdose4u Thank you❤️ for all the efforts bro.

    • @techdose4u
      @techdose4u  3 года назад +2

      Welcome bro 😊 keep helping others as well :)

    • @jiosim1377
      @jiosim1377 3 года назад

      What questions were asked in the interview?

  • @iamparitosh
    @iamparitosh 3 года назад +8

    I would highly recommend of your videos for everyone who finds it difficult to understand concepts easily as your video even explain the obvious things which may not be obvious for some.

  • @MahirHasancse21
    @MahirHasancse21 3 года назад +1

    Best Explanation.
    I want ask you the question about complexity.
    In the time complexity,
    1. For 1st k+1 element build heap = O(k+1)
    2. For remaining n-k+1 element push in the heap = O((n-k+1)logk)
    3. For remaining n-k+1 element pop from the heap = O((n-k+1)logk)
    4. For remaining k+1 element pop from the heap = (k+1log k)+(klog k-1)+(k-1log k-2)+...+(k-k+1log k-k)
    5. Traversing the whole array = O(n)
    Is it correct?
    What will be the complexity for the point no. 4?

    • @techdose4u
      @techdose4u  3 года назад +1

      You can take it KlogK. It will be an upper bound. Time will be lesser due to decreasing heapsize.

    • @MahirHasancse21
      @MahirHasancse21 3 года назад +1

      @@techdose4u Thank you very much❤️

    • @techdose4u
      @techdose4u  3 года назад

      Welcome

  • @AltafHussain-on2oe
    @AltafHussain-on2oe 3 года назад +2

    Thank You Sir for Explaining in such a easy way.

  • @krishnavamsichinnapareddy
    @krishnavamsichinnapareddy Год назад +1

    Superb explanation ❤

  • @preetamramdhave9807
    @preetamramdhave9807 3 года назад +3

    This is really nice work. I have seen some other videos also from you . All are very good and easily explain. Very good work. The way you explain we can easly code the solution and understand the approach as well as the algorithm also. Apricate your work.

  • @anonymousanonymous7507
    @anonymousanonymous7507 10 месяцев назад +1

    Instead of copy pasting code from gfg ,show ur own code, code of gfg can be made much simpler

  • @pujabhardwaj7569
    @pujabhardwaj7569 2 года назад +1

    Thank you so much for such great tutorials..... really helpful

  • @mohammadyahya78
    @mohammadyahya78 3 года назад

    Thank you very much. Clear explanation, but I have one question at 12:58 please. Why you took please 2 and added to array when you reached 8? What if the min element is the last element? I mean if 2 is at position of 9 instead of 3?

  • @Somethingsomethinglol
    @Somethingsomethinglol 3 года назад

    Question: Around 12:40 you mention that we do the extract min operation (to get the 2) and then we insert the next value (8). Shouldn't we insert first and then extract? Suppose instead of the next value being 8, it were 0. Wouldn't we want to insert that 0, min heapify the heap, then extract the root (0) ?
    Thank you for this series! I've spent the weekend going through this playlist. Incredibly helpful.

    • @Somethingsomethinglol
      @Somethingsomethinglol 3 года назад

      Ah! In my made up example, 0 would be in an invalid spot because it would be > k spaces away from where it should be.

  • @jayneversettle
    @jayneversettle 2 года назад

    Hi Dawg, Beautiful explanation. But why were you sayin "we gotta use minHeapy() etc etc..." when all we are using is a priority queue in Java and C++.
    And In the interview, Its okay to use PriorityQueue right? I mean we don't have to implement the entire algorithm from the base and create a minHeapify() method right?

  • @vasudevrao1434
    @vasudevrao1434 3 года назад +1

    After k+1 times we are just removing min and adding a new element.
    For removing min we do heapify and then again to add new element we do bottom up algo.
    Rather then doing that cant we just replace the min element with the new element and do a heapfy ?
    Pls Correct me if m wrong.

    • @techdose4u
      @techdose4u  3 года назад

      I think your library will not allow it. You can try doing.

  • @shalinshikhar8403
    @shalinshikhar8403 2 года назад

    The code for insertion sort which is shown at the last is not using the property of k sorted..can anyone clarify??

  • @hizmzmhei8824
    @hizmzmhei8824 3 года назад +1

    Hello Sir, I am big fan of your work. I have a question from dynamic programming. Could you please share email so that I can send you. I am unable to solve that question. You can even make a video on that.

    • @techdose4u
      @techdose4u  3 года назад

      Hi. It's on my channel info page.

    • @hizmzmhei8824
      @hizmzmhei8824 3 года назад

      @@techdose4u it's LEETCODE 691.

  • @debasishparamanik6527
    @debasishparamanik6527 3 года назад

    why is the size of heap k+1?

    • @glenfernandes9038
      @glenfernandes9038 3 года назад

      so that we don't have to use all n elements to sort the array in which case the time complexity would be of logn order. We are making use of the fact that all elements are just k distance away from current index at max and therefore decrease time complexity accordingly.

  • @venkatkrishna3774
    @venkatkrishna3774 3 года назад +3

    not good. you did not explain the intuition behind using min heap to solve this problem

  • @omkarkawatgi
    @omkarkawatgi 2 года назад

    You teach less and promote your other videos more ! Not good explaining !