why STL set size complexity is O(1), how is it calculated? -
a set internally maintained balanced binary tree. complexity calculate size of set o(1). how size calculated, maintain variable store size.
the specification states set
s (actually, containers) have size()
member function takes constant time. other that, implementers of particular version of standard library may have done wished, long it's o(1)
.
in practice, size may stored in member variable gets updated items inserted or removed; piotrnycz' implementers have done that.
Comments
Post a Comment