Which of the following principle does stack use?

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

Which of the following principle does stack use?

(A). Linear data structure

(B). LIFO

(C). Hierarchical data structure

(D). None of these

Question’s Answer: LIFO

FIFO means first element added to the queue is the first one to be removed from queue.

Data StructurePrinciple
StackLIFO
QueueFIFO
Arraylinear data structure without an inherent ordering principle
Treehierarchical data structure without an inherent ordering principle
Linked Listlinear data structure without an inherent ordering principle

Example

Output

3 pushed into stack
7 pushed into stack
1 pushed into stack
1 Popped from stack
Top element is : 7
Elements present in stack : 7 3