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?

  1. 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.
  2. 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.
  3. CA stack follows a LIFO (last-in, first-out) order, while a queue follows a FIFO (first-in, first-out) order.
  4. 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)

This is question 133 of DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 3 (4:30 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.