How the size of a vector increases once it is full?

Đức Lưu

New member
How the size of a vector increases once it is full?
A. Vector increases its capacity one by one
B. Vector doubles its capacity after it is full
C. Vector increases its capacity by half of its previous size
D. Vector increases its capacity by a constant factor
 
Answer: b
Explanation: Once the vector is full i.e. number of elements in the vector becomes equal to the capacity of the vector then vector doubles its capacity i.e. if previous capacity was 2 then new capacity becomes 2 * 2 = 4 or 2 + 2 = 4.
 

Tìm kiếm

Back
Top