Suggest changes to make the time a function of input size
Posted
by KB
on Stack Overflow
See other posts from Stack Overflow
or by KB
Published on 2010-04-16T08:26:12Z
Indexed on
2010/04/16
8:33 UTC
Read the original article
Hit count: 239
stl
Vector v; int i=0; while(i!=999) { cin>>i; v.push_back(i); }
Time taken by this piece of code could vary when the number of inputs vary. Since vector would take amortized time for new allocation. Even for same size the program at different times could take different time.
Suggest changes (e.g. use list instead of vector), which makes the time a function of number of inputs.
© Stack Overflow or respective owner