Aug 28, 2013 at 1:29pm
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 Aug 28, 2013 at 1:55pm
Aug 28, 2013 at 6:22pm
Time to ask help of USA folks? Boys, any resonable thoughts would be very helpfull.
Aug 29, 2013 at 3:01am
The reference on this website documents the complexity of those functions.
Aug 29, 2013 at 5:01pm
Thank you all. The answer has been figured out by myself.