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!!!
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.
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?
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.
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?
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.
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?
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.
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.
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.
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!!!
Woww great ❤️Congratulations🎉 Happy to hear this 😀 I feel proud 😁 Wish you all the best for your job offer.
@@techdose4u Thank you❤️ for all the efforts bro.
Welcome bro 😊 keep helping others as well :)
What questions were asked in the interview?
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.
Thanks :)
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?
You can take it KlogK. It will be an upper bound. Time will be lesser due to decreasing heapsize.
@@techdose4u Thank you very much❤️
Welcome
Thank You Sir for Explaining in such a easy way.
Welcome :)
Superb explanation ❤
Thanks :)
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.
Thanks :)
Instead of copy pasting code from gfg ,show ur own code, code of gfg can be made much simpler
Thank you so much for such great tutorials..... really helpful
Welcome 😀
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?
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.
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.
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?
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.
I think your library will not allow it. You can try doing.
The code for insertion sort which is shown at the last is not using the property of k sorted..can anyone clarify??
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.
Hi. It's on my channel info page.
@@techdose4u it's LEETCODE 691.
why is the size of heap k+1?
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.
not good. you did not explain the intuition behind using min heap to solve this problem
He just copy pastes gfg codes and bring his own theory
You teach less and promote your other videos more ! Not good explaining !