> Code N dragon

Queue

A stack is a data structure that follows the FILO (First In, Last Out) principle. It means that the last element added to the stack is the first one to be removed.

4

1

24

8

9

Here, only the last element added can be removed, which is the value 4.

Example Operations

Push

We want to add the number 13 to the queue.

4

1

24

8

9

We add the number 13 to the end of the queue. It will be the last element to be popped from the queue.

4

1

24

8

9

13

Pop

We want to get the next element in the queue, which is the first element that was added.

4

1

24

8

9

We can see that the first element is 4, so we will remove it from the queue.

1

24

8

9