As mention by bhaiya if we want top 3 elements in the heaps it will going to take the 3logN time so, the lgN complexity is for removing the element in the heaps and to view the top element it will takes 0(1) constant time??
Priority class complexity
hello @Vikaspal
heap allow us to view top element in O(1). but here we need to get top 3 elements.
for that we need to perform remove operation on the heap whch is O(logn) per remove operations. for 3 operation it will be 3 *log(N)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.