Monday, March 4, 2013

Just spent 2 hours working on a linked-list assignment, wondering why pop_back on a list with a million elements was taking well over 10 minutes to complete when it should have taken less than a second.

Turns out that I forgot it was a doubly-linked list, and was iterating to the end from the head for each insertion. That would have made insertion of a million elements be (10^6)!, or a million factorial.

Whoa nelly.

No comments: