Given that the heapq is the minimum stack in the dragon as specified in the dragon doctor, suppose i have elements There is a hap with, what is the timing complexity of call? I do not think that complexity is O (n * lg (m)) because only you get the best while sliding the root and again covering it in a heap?
You can see the code, assuming that you heapq Nlargest (n, this)
, where is an iterable with the
m
elements; first of n
elements < Creates a minimum stack with code> it . Then, the mn
element for the rest, if they are larger than the root, then it takes the root out, holds the new element, and takes it down. Finally, the complexity O (log (n) * m)
.
No comments:
Post a Comment