HOSTEL VISIT CPP


is my approach wrong? i am not getting the expected output.

hi @Kush_1312 the thing about heaps is that they’re useful only to access the greatest or smallest element. Rest of the “heap” is not sorted, so it doesn’t guarantee that you will get the “3rd smallest element” by accessing a certain index.
for eg if a heap is like this
1
5 4
10 12, 8 9
(sorry im unable to visualise the “tree” shape properly here)
the vector will look like this 1 5 4 10 12 8 9