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 sets (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

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -