13.7k views
0 votes
Unlike a stack, the items in a queue don't always ________

1 Answer

5 votes

Final answer:

A queue is a data structure that follows the principle of First-In-First-Out (FIFO). Items in a queue don't always come out in the same order they were put in.

Step-by-step explanation:

A queue is a data structure that follows the principle of First-In-First-Out (FIFO), meaning that the items are processed in the order they were added. Unlike a stack, items in a queue don't always come out in the same order they were put in. Instead, the first item that was added (the front of the queue) is the first one to be removed.

For example, imagine a queue of people waiting in line to buy tickets for a movie. The person who arrived first will be the first one to buy a ticket and leave the queue. The second person in line will buy a ticket after the first person, and so on.

In programming, queues are commonly used in situations where the order of processing is important, such as handling events or managing tasks.

User Freefaller
by
8.7k points