Data Structures & AlgorithmsModerateIBM · Deloitte pattern

What is the minimum stack size needed to evaluate the postfix expression a b c d + * e f − / + ?

  1. A. 3
  2. B. 5
  3. C. 4
  4. D. 11

Correct answer: C. 4

Stack depth after each token: 1, 2, 3, 4 (after d), 3, 2, 3, 4 (after f), 3, 2, 1. The peak is 4, so a stack of 4 is enough.

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

Exams that ask this topic