Data Structures & AlgorithmsModerateTCS NQT · Accenture

A stack starts empty. Operations in order: push 1, push 2, pop, push 3, push 4, pop, pop. Write each popped value in order and read the result as one integer. What integer is produced?

  1. A. 244
  2. B. 241
  3. C. 255
  4. D. 243

Correct answer: D. 243

The pops return 2, then 4, then 3, giving the digits 2, 4, 3 in that order. Reading the pops as a queue would give a different order.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic