先决条件–编程中的FIFO(先进先出)方法
FIFO是先入先出的缩写。这是一种用于处理数据结构的方法,其中首先处理第一个元素,最后处理最新的元素。
现实生活中的例子:
LIFO是“后进先出”的缩写,与“拳头后进” (FILO)相同。它是一种处理数据结构的方法,其中最后一个元素首先被处理,而第一个元素最后被处理。
现实生活中的例子:
以下是FIFO与LIFO的比较:
FIFO | LIFO |
---|---|
It stands for First-In-First-Out approach in programming. | It stands for Last-In-First-Out approach in programming. |
In this, the new element is inserted below the existing element, So that the oldest element can be at the top and taken out first. | In this, the new element is inserted above the existing element, So that the newest element can be at the top and taken out first. |
Therefore, the First element to be entered in this approach, gets out First. | Therefore, the First element to be entered in this approach, gets out Last. |
In computing, FIFO approach is used as an operating system algorithm, which gives every process CPU time in the order they arrive. | In computing, LIFO approach is used as a queuing theory that refers to the way items are stored in types of data structures. |
The data structure that implements FIFO is Queue. | The data structure that implements LIFO is Stack. |