Why does std::list::reverse have O(n) complexity?
Hypothetically, reverse could have been O(1). There (again hypothetically) could have been a boolean list member indicating whether the direction of the linked list is currently the same or opposite as the original one where the list was created. Unfortunately, that would reduce the performance of basically any other operation (albeit without changing the asymptotic … Read more