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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -