Priority queue STL 01

why 3 does not occur in the output
when the input is 1 10 7 4 3
???

why only 10 7 4 1 occurs in the output

Hello @nihalsarawgi1999,

The output is correct as per the code.
If you see the input for loop carefully,
It is executing n-1 times i.e. 4 times for this example.
So, we are not reading 3 (being the 5th element).
Hence, it is not the part of the heap that we have created.

Hope, this would help.
Give a like if you are satisfied.

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.