4 ms·
I'm not sure how LinkedList insert/delete performance isn't O(n) where n is the list length - care to shed some light? Are you assuming you have a node in the
by swsieber 10y ago
I'm not sure how LinkedList insert/delete performance isn't O(n) where n is the list length - care to shed some light?
Are you assuming you have a node in the linked list? That might be constant, but the standard is to remove by index, and that's O(n).
- brown9-2 10y agoAh, I was assuming foolishly that we were talking about removing or inserting only at the head or the tail. All the more reason to be more detailed in a writeup than simply "Performance: O(n)" :)