2 ms·
In the real world it's almost certain that somebody else already paid the traversal cost in making the decision of what to act on. The only common cases where
by LorenPechtel 4y ago
In the real world it's almost certain that somebody else already paid the traversal cost in making the decision of what to act on. The only common cases where that doesn't apply are removing the head (think queue) and adding the tail. The latter case can be handled by keeping a pointer to the tail in your control structure.
A queue very well might be best implemented as a linked list rather than an array.