3 ms·
Of course, it depends on the language. If you're using a language with linked lists, appending is the wrong way to do it. :) On a different note: it's nice to
by TazeTSchnitzel 12y ago
Of course, it depends on the language. If you're using a language with linked lists, appending is the wrong way to do it. :)
On a different note: it's nice to see this here, it validates my choice to .reverse() and .push() when using an array as a queue today.
- wfunction 12y agoLinked lists are only useful in very few situations and this is not one of them.
- Niksko 12y agoI've been terrified of linked structures since I saw a video (I think it was here) from a C++ conference talking about how horrible their performance is.
- adsr 12y agoYou could keep pointers to both the head and tail in the list object though. Then adding and removing stuff would be O(1) for both ends.
- thaumaturgy 12y agoYep, and that used to be idiomatic, years and years ago when people still wrote their own linked lists. I'd be surprised if it isn't still the standard behavior for that data structure.