The Queue data structure is said to follow the FIFO strategy. What does this mean ?
views:
211answers:
5FIFO means "First In First Out". The first item you put in is the first to come out:
Put(1)
Put(2)
Put(3)
Get() returns 1
Get() returns 2
Get() returns 3
Why don't you stop asking questions for each and every class/term you encounter and go back and read and do some thinking. With all these questions and answers flying back there is no way you understand each and every reply. Do a bit of reading first so you have some background - as it appears you have very little understanding and are asking questions ad nauseum.
First in, first out. Items are returned by pull()
in the same order that they are added to the queue via offer(E)
.
First in, first out. As in, the first element to be entered into the queue is the first element to exit the queue. Think of a lineup at your favorite grocery store.
This is opposed to a stack, which is LILO (last in, last out). In this case, you can think of a stack of plates. The last plate you add to the stack is the first one you're going to remove when you go to make yourself a snack ;)
Picture the FIFO "strategy" as a regular queue. People waiting in line for the theater:
The First one to get In to the line is also the First one to get Out the line and into the theater.