What is the underlying data structure of stack and queue?
Answers
Answer:
Stacks are based on the LIFO principle, i.e., the element inserted at the last, is the first element to come out of the list
. Queues are based on the FIFO principle, i.e., the element inserted at the first, is the first element to come out of the list.
Answer: Stacks and Queues
Explanation: Stacks
A stack is defined by having a LIFO (Last In First Out) ordering principle. The first element added to a stack is the last to be removed. Equivalently, the last element added to a stack is the first to be removed. Operations that act on a stack have a unique terminology:
Push - add a new element to the stack.
Pop - remove an element from the stack.
Queues
A queue is defined by having a FIFO (First In First Out) ordering principle. The first element added to a queue is the first to be removed and the last element to be added to a queue will be the last to be removed. The terminology for operations that act on queues is as follows:
Enqueue - add a new element to the queue.
Dequeue - remove an element from the queue.
#answerwithquality & #BAL