tag:blogger.com,1999:blog-5744242424691579612.post781236427194686007..comments2022-03-24T04:27:50.388-07:00Comments on C Linux Code/Question asked in recent real company interviews: STL Vector example in C++ in Linux all operationsRajhttp://www.blogger.com/profile/03434858315793010336noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-5744242424691579612.post-51918159912141657802017-05-07T12:01:20.553-07:002017-05-07T12:01:20.553-07:00Vector is internally implemented using arrays and ...Vector is internally implemented using arrays and this array grows dynamically. There is some memory strategy that vector uses when it grows.Vector has two properties<br />1) Size() -number of elements in the vector<br />2) Capacity(): total amount of memory available to store elements in terms of elements.<br /><br />Initially vector will be empty and the space allocated (capacity) is zero.When we keep on adding elements to the vector size increases one by one , but capacity increases not one by one but with some factor. That factor depends upon the<br />Compiler used. In gcc compilers it is of the order of 2;ie 1,2,4,8 etc. In MSVC it is different.Manoj Sahuhttps://www.blogger.com/profile/02210078217195648935noreply@blogger.com