In which scenario would a stack be preferred over a queue?
-
When processing tasks in a last-in, first-out manner
-
When tasks need to be processed in the order they arrive
-
When implementing breadth-first search
-
When managing a list of items to be displayed