Hello,
Could someone to help determine complexity of the following code blocks:
1.
1 2 3 4
|
for(size_t i = 0; i < v.size() - 1; ++i) {
std::sort(v.begin()+i, v.end());
v[i+1] += v[i];
}
|
2.
1 2 3 4
|
for(size_t i = 0; i < v.size() - 1; ++i) {
std::partial_sort(v.begin() + i, v.begin() + i + 2, v.end());
v[i+1] += v[i];
}
|
And how calculation time will be changed if number of elements will be increased in 1000 times?
Thanks in advance.
Last edited on
Time to ask help of USA folks? Boys, any resonable thoughts would be very helpfull.
The reference on this website documents the complexity of those functions.
Thank you all. The answer has been figured out by myself.