Question 9Asked in UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)

Consider the following statements : S₁ : A queue can be implemented using two stacks. S₂ : A stack can be implemented using two queues. Which of the…

Consider the following statements : S₁ : A queue can be implemented using two stacks. S₂ : A stack can be implemented using two queues. Which of the following is correct?
  1. AS₁ is correct and S₂ is not correct
  2. BS₁ is not correct and S₂ is correct
  3. CBoth S₁ and S₂ are correct
  4. DBoth S₁ and S₂ are not correct
Show answerHide answer

Correct answer: (C) Both S₁ and S₂ are correct

Explanation

A queue can be implemented using two stacks S1 and S2: enqueue pushes onto S1; for dequeue, if S2 is not empty pop from it, otherwise first pop all elements of S1 and push them into S2, then pop from S2. So S₁ is correct. Similarly, a stack can be implemented using two queues, so S₂ is also correct. Hence, the answer is option (c).

From UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions)

This is question 9 of UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions). 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.