Data Structures & AlgorithmsHardHCLTech · Wipro pattern
What is the postfix (Reverse Polish) form of the infix expression "e *(a + b)- h / d", built with the standard stack-based conversion (^ right-associative, others left-associative)?
- A. - / d h * + b a e
- B. e a b + * h - d /
- C. e a b + * h d / -
- D. e a b h d / - + *
Correct answer: C. e a b + * h d / -
Using a stack to hold pending operators and popping higher-or-equal precedence operators before pushing a new one (left-associative) gives "e a b + * h d / -". Treating all operators as equal precedence instead would wrongly give "e a b + * h - d /".
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- A circular queue of capacity 5 starts empty and runs this sequence in order: enqueue(2), enqueue(3), enqueue(3), enqueue(2), enqueue(3)…
- A queue is implemented with two stacks (enqueue pushes to stack "in"; dequeue pops from stack "out", refilling "out" from "in" by…
- Keys 26, 63, 80, 39, 14, 99, 18, 93, 44 are inserted via linear probing (h(k) = k mod 11, probe by +1 on collision) into an initially…
- A circular queue of capacity 4 starts empty and runs this sequence in order: enqueue(3), enqueue(1), enqueue(6), enqueue(9), dequeue()…
- What is the postfix (Reverse Polish) form of the infix expression "i (f + c)- a / h", built with the standard stack-based conversion (^…
- Array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] is left-rotated by d = 1 positions using the reversal algorithm (reverse first d, reverse rest…