Question 133Asked in DSSSB TGT Computer Science, 25 Jun 2023, Shift 3 (4:30 PM)
What is the main difference between a stack and a queue data structure?
AA queue is more efficient for inserting and deleting elements at any position, while a stack is more efficient for inserting and deleting elements at the front and back.
BA stack is more efficient for inserting and deleting elements at any position, while a queue is more efficient for inserting and deleting elements at the front and back.
CA stack follows a LIFO (last-in, first-out) order, while a queue follows a FIFO (first-in, first-out) order.
DA queue follows a LIFO (last-in, first-out) order, while a stack follows a FIFO (first-in, first-out) order.
Show answerHide answer
Correct answer: (C) A stack follows a LIFO (last-in, first-out) order, while a queue follows a FIFO (first-in, first-out) order.
Explanation
A stack is LIFO: the last element pushed is the first popped. A queue is FIFO: the first element enqueued is the first dequeued.
From DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 3 (4:30 PM)