Predictably, question 6 fails the most – the answer is different for C ++ 11 and C ++ 98. Moreover, in the new standard, the function began to work worse.
In the test, you were asked to evaluate the correctness and computational complexity of 6 different solutions to the same problem:
Here a new (initially empty) list is created, into which the elements placed between the [a, b] iterators are sequentially added. The viewed items are removed from the old list. Moreover, if the iterator b points to source.end (), then there is no need to move the corresponding element, otherwise, b is shifted to the right (b = next (b)). This code works great in O (M), since push_back and erase are O (1). You can read more about the estimation of the complexity of algorithms in the article “Analysis of the complexity of algorithms.