Which of the following is a LIFO (Last In, First Out) data structure?

By: Prof. Dr. Fazal Rehman | Last updated: February 3, 2024

Question:  Which of the following is a LIFO (Last In, First Out) data structure?

A   Queue

B    Stack

C   Linked List

D   Array

Answer:   Stack

 

Characteristic            LIFO             FIFO
Full form ·        Last In, First Out ·        First In, First Out
Principle ·        The last item added is the first one to be removed. ·        The first item added is the first one to be removed.
Data Structure Examples ·        Stack ·        Queue
Behavior ·        New elements are added to the top (push) and removed from the top (pop). ·        New elements are added at the rear (enqueue) and removed from the front (dequeue).
Real-World Analogy ·        Stack of plates – the last plate added is the first to be used. ·        A line of people waiting in a queue, where the person at the front goes first.
Applications ·        Undo functionality in software applications

·        function call management

·        Managing function call history in a web browser.

·        Print job management

·        task scheduling

·        Process management in operating systems

 

 

All Copyrights Reserved 2025 Reserved by T4Tutorials