[Data structure] Queue, stack and ring buffer

Aug 26, 2020 PHP algorithms data structures

Queue structure

The queue structure is a data structure where people wait in line at the counter. Data is added to the end of the row and the data is used in order from the beginning. In other words, the queue structure will use the first put data first. It is called FIFO because it is first in, first out. Putting data in the queue is called Enqueue, and taking it out is called Dequeue.

Stack structure

The stack structure uses the last put data first. Also called LIFO because it is last in, first out. Putting data on the stack is called Push, and pushing it out is called Pop. The last part of the stack, which is used at the end and is used first, is called the stack top.

Ring buffer

The ring buffer is a data structure in which data is arranged in a ring. In other words, it is a ring-shaped data structure in which the top (top) and the end (bottom) of the data sequence are connected. It is used when overwriting old data with the latest contents and always storing constant data.