Following is text snippet from Algorithms in C++ by Robert Sedwick on queues.
Although many applications that involve a queue of pending work
operate correctly no matter what rule is used to remove, the overall
running time or other resouce usage may be dependent on the rule. When
such applications involve a large number of “insert” and “remove”
operations on data structures with a large number of items in them,
performance differences are paramount.
My question is we have rule for removing for example LIFO queue removing last in last out, and for queue it is FIFO, but how it is related to insert for large number of items in them as mentioned in above paragraph. Can any one re-phrase above paragraph to have a clear understanding.
Thanks!
What I think the author means is that you can simply use a FIFO or a LIFO queue, but better performance can be acquired in some scenarios by using an algorithm that tackles resource-heavy items in the queue first.
Take for example an airport. A lot of suitcases come in at the check-in department. You can store them in the airplane in the same order they came in (FIFO), or you can put the large ones in first and then store the small ones, giving better storage use.