answersLogoWhite

0


Best Answer

S: Stack

while(more tokens)

{

x<-next token;

if(x is an operand)

print x

else

{

while(precedence(x) <= precedence(top(s))

print(pop(s))

push(s,x)

}

}

while(!empty(s))

print(pop(s));

Written by: Fabianski Benjamin

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

STACK

the STACK data structure can be implemented in java through ARRAYs and LINKED LISTS.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

it is needed in compiler designing

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

A stack.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which data structure is needed to convert infix notations to pre fix notations?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why do compilers convert infix expressions to postfix?

people almost exclusively use infix notation to write mathematical expressions, computer languages almost exclusively allow programmers to use infix notation. However, if a compiler allowed infix expressions into the binary code used in the compiled version of a program, the resulting code would be larger than needed and very inefficient. Because of this, compilers convert infix expressions into postfix notation expressions, which have a much simpler set of rules for expression evaluation. Postfix notation gets its name from the fact that operators in a postfix expression follow the operands that they specify an operation on. Here are some examples of equivalent infix and postfix expressions Infix Notation Postfix Notation 2 + 3 2 3 + 2 + 3 * 6 3 6 * 2 + (2 + 3) * 6 2 3 + 6 * A / (B * C) + D * E - A - C A B C * / D E * + A C * - Where as infix notation expressions need a long list or rules for evaluation, postfix expressions need very few.


Who invented postfix and infix?

infix: old Egyptians/Assirs some thousands year before prefix: Jan &#321;ukasiewicz (Polish Notation) postfix: Burks, Warren, and Wright (Reverse Polish Notation)


How do you convert a prefix expression to postfix using recursion?

struct stack { char ele; struct stack *next; }; void push(int); int pop(); int precedence(char); struct stack *top = NULL; int main() { char infix[20], postfix[20]; int i=0,j=0; printf("ENTER INFIX EXPRESSION: "); gets(infix); while(infix[i]!='\0') { if(isalnum(infix[i])) postfix[j++]=infix[i]; else { if(top==NULL) push(infix[i]); else { while(top!=NULL &amp;&amp; (precedence(top-&gt;ele)&gt;=precedence(infix[i]))) postfix[j++]=pop(); push(infix[i]); } } ++i; } while(top!=NULL) postfix[j++]=pop(); postfix[j]='\0'; puts(postfix); getchar(); return 0; } int precedence(char x) { switch(x) { case '^': return 4; case '*': case '/': return 3; case '+': case '-': return 2; default: return 0; } } void push(int x) { int item; struct stack *tmp; if(top==NULL) { top=(struct stack *)malloc(sizeof(struct stack)); top-&gt;ele=x; top-&gt;next=NULL; } else { tmp=top; top-&gt;ele=x; top-&gt;next=tmp; } } int pop() { struct stack *tmp; int item; if(top==NULL) puts("EMPTY STACK"); else if(top-&gt;next==NULL) { tmp=top; item=top-&gt;ele; top=NULL; free(tmp); } else { tmp=top; item=top-&gt;ele; top=top-&gt;next; free(tmp); } return item; }


What is the time complexity of infix to post fix conversion algorithm?

O(nlogn)


How can you convert an infix notation to postfix notation?

#include &lt;iostream&gt; #include &lt;stack&gt; using namespace std; int prec (char ch){ // Gives precedence to different operators switch (ch) { case '^': return 5; case '/': return 4; case '*': return 4; case '+': return 2; case '-': return 1; default : return 0; } } bool isOperand(char ch){ // Finds out is a character is an operand or not if ((ch&gt;='0' &amp;&amp; ch&lt;='9') (ch&gt;='a' &amp;&amp; ch&lt;='z')) return true; else return false; } string postFix (string infix){ string pfix = ""; stack&lt;char&gt; opstack; for (int i=0; i&lt;infix.length(); i++){ // Scan character by character if (isOperand(infix[i])) { pfix += infix[i]; } else if (infix[i] ')') { // Retrace to last ( closure while (opstack.top() != '(') { pfix += opstack.top(); opstack.pop(); } // Remove the '(' found by while loop opstack.pop(); }

Related questions

Which data structure is needed to convert infix notations to post fix notations?

stack is the basic data structure needed to convert infix notation to postfix


Which data structure convert logical to physical address?

Linear data structure is used to convert the logical address to physical address .Stack is used in this and the various conversion such as postfix,prefix and infix notation are come in this


Convert infix to prefix to postfix?

(a + b) * c / ((x - y) * z)


Program to convert infix to prefix?

I dont have the idea about the program but I know that prefix means the first starting letters of a particular things. I really think so there is a progam to convert infix to prefix but i might have misunderstood your question can you make it little simpler please.


Why you need convert a expression into postfix expression?

You convert an (infix) expression into a postfix expression as part of the process of generating code to evaluate that expression.


Write an algorithm in c to convert an infix expression to a postfix expressionexecute your algorithm with the following infix expression as your input. m nk pgh a bc?

An algorithm can not be written with the following infix expression without knowing what the expression is. Once this information is included a person will be able to know how to write the algorithm.


Why do compilers convert infix expressions to postfix?

people almost exclusively use infix notation to write mathematical expressions, computer languages almost exclusively allow programmers to use infix notation. However, if a compiler allowed infix expressions into the binary code used in the compiled version of a program, the resulting code would be larger than needed and very inefficient. Because of this, compilers convert infix expressions into postfix notation expressions, which have a much simpler set of rules for expression evaluation. Postfix notation gets its name from the fact that operators in a postfix expression follow the operands that they specify an operation on. Here are some examples of equivalent infix and postfix expressions Infix Notation Postfix Notation 2 + 3 2 3 + 2 + 3 * 6 3 6 * 2 + (2 + 3) * 6 2 3 + 6 * A / (B * C) + D * E - A - C A B C * / D E * + A C * - Where as infix notation expressions need a long list or rules for evaluation, postfix expressions need very few.


How do you convert infix to postfix without using data structures?

Without data-structures you cannot even store expressions, let alone convert or evaluate them.


What actors and actresses appeared in Index of Infix - 2004?

The cast of Index of Infix - 2004 includes: Infix as Themselves


Give you 5 examples of infix?

give 5 examples of infix


What is the in the middle of prefixes and suffixes?

Infix


What is the meaning of infix?

To set; to fasten or fix by piercing or thrusting in; as, to infix a sting, spear, or dart., To implant or fix; to instill; to inculcate, as principles, thoughts, or instructions; as, to infix good principles in the mind, or ideas in the memory., Something infixed.