The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+18 votes
1.9k views

Which of the following is essential for converting an infix expression to the postfix form efficiently?

  1. An operator stack
  2. An operand stack
  3. An operand stack and an operator stack
  4. A parse tree
asked in DS by Veteran (59.5k points)
edited by | 1.9k views

2 Answers

+18 votes
Best answer

A. An operator stack    // Infix to ( Postfix or Prefix )

B. An operand stack    //Postfix or Prefix Evaluation

C. An operand stack and an operator stack //we never use two stacks

But for Prefix to (Infix or postfix)  OR   Postfix to (Infix or prefix)  We can use a stack where both operator and operand can present simultaneously

D. A parse tree  // Not relevant to this question

Hence, Option A is Answer.

http://condor.depaul.edu/ichu/csc415/notes/notes9/Infix.htm is a good read.

answered by Boss (22.8k points)
edited by
0

Hello Rajesh

Are you sure to evaluate prefix expression we need only one stack ?

Attaching source for detailed answer.

https://en.wikibooks.org/wiki/Data_Structures/Stacks_and_Queues

+24 votes
A.

we use operator stack (only operators are pushed as +, *, (, ), / ) for converting infix to postfix. And we use operand stack( operands such as 5,4,17 etc) for postfix evaluation.
answered by Boss (19.7k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

39,440 questions
46,623 answers
139,377 comments
57,024 users