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.
int pop_front(int idx) //WTF am I smoking?

This is the thing you get up to when you code at 3am.
Context : Working on a doubly-linked list for a school assignment.