Policy based data structure

Can’t we get the Kth largest element by simply iteration over the set K times instead of using find_by_order() ?
Since both are going to take O(logn) time.
What’s the added advantage of PBDS?

hello @subhamjaiswal885

in case of set it will be O(K) … becuase u will use loop that will run to k times.

whereas find by order will take O(LOGN) were N is the number of elements in ur pbds.

Ok i got it.Thank you!!

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.