convert infix to postfix expression and show trace of algorithm?
Q. Convert the infix expression (A - B) * C + D to postfix. Show the trace of the algorithm, i.e., the stack, the infix expression and postfix expression.
Asked by bc050400307 - Wed Aug 15 00:29:21 2007 - - 1 Answers - 0 Comments
A. a b - c * d + stack trace. [a-b] means a single element that represents the value of a-b. a a b a b - [a-b] [a-b] c [a-b] c * [(a-b)*c] [(a-b)*c] d [(a-b)*c] d + [(a-b)*c + d]
Answered by anonymous - Wed Aug 15 01:12:10 2007
Q. Convert the infix expression (A - B) * C + D to postfix. Show the trace of the algorithm, i.e., the stack, the infix expression and postfix expression.
Asked by bc050400307 - Wed Aug 15 00:29:21 2007 - - 1 Answers - 0 Comments
A. a b - c * d + stack trace. [a-b] means a single element that represents the value of a-b. a a b a b - [a-b] [a-b] c [a-b] c * [(a-b)*c] [(a-b)*c] d [(a-b)*c] d + [(a-b)*c + d]
Answered by anonymous - Wed Aug 15 01:12:10 2007
Can you give me a program to convert infix expression to a postfix expression?
Q. the program should be in c language and implement stack in it. please give me a working code or a link to the same
Asked by anku - Mon Aug 31 01:58:29 2009 - - 2 Answers - 0 Comments
A. You can read the expression put each element it in the stack and retrieve it and place the operators after the operands. Here is a link that answers your question : Don't copy the code from there just use it as a reference else it will be cheating and you will not learn anything. Good Luck!!!
Answered by abc - Mon Aug 31 02:31:31 2009
Q. the program should be in c language and implement stack in it. please give me a working code or a link to the same
Asked by anku - Mon Aug 31 01:58:29 2009 - - 2 Answers - 0 Comments
A. You can read the expression put each element it in the stack and retrieve it and place the operators after the operands. Here is a link that answers your question : Don't copy the code from there just use it as a reference else it will be cheating and you will not learn anything. Good Luck!!!
Answered by abc - Mon Aug 31 02:31:31 2009
Write a program to convert the infix input expression into postfix expression?
Q. Example Input infix expression 5*(((9+8)*(4*6) +7) Result postfix expression 598+46**7+*
Asked by swetha b - Sun Aug 19 01:22:26 2007 - - 1 Answers - 0 Comments
A. Do your own homework.
Answered by Popsmear - Sun Aug 19 01:29:07 2007
Q. Example Input infix expression 5*(((9+8)*(4*6) +7) Result postfix expression 598+46**7+*
Asked by swetha b - Sun Aug 19 01:22:26 2007 - - 1 Answers - 0 Comments
A. Do your own homework.
Answered by Popsmear - Sun Aug 19 01:29:07 2007
Could anyone please kindly check my answer (regarding the conversion from infix notation to postfix notation)?
Q. So: Infix Notation: A/(B+C*D)*E-F My answer (in Postfix Notation) : AB+CD*/EF*- Is my answer right? If not, can you please help me? Please only answer if you can really help me... Thanks a lot!
Asked by europhile - Sat Feb 9 03:36:53 2008 - - 1 Answers - 0 Comments
A. The layout of the infix statement does not make it clear if the factor E is in the numerator or the denominator.
Answered by openmath - Sat Feb 9 05:11:52 2008
Q. So: Infix Notation: A/(B+C*D)*E-F My answer (in Postfix Notation) : AB+CD*/EF*- Is my answer right? If not, can you please help me? Please only answer if you can really help me... Thanks a lot!
Asked by europhile - Sat Feb 9 03:36:53 2008 - - 1 Answers - 0 Comments
A. The layout of the infix statement does not make it clear if the factor E is in the numerator or the denominator.
Answered by openmath - Sat Feb 9 05:11:52 2008
Can you give me a program that convert infix to postfix of 3*5+6 using java language?
Q. with corresponding output like: token output stack (bottom to up) --- --- --- i would appreciate if comments included. thanks, i'll give you best answer..
Asked by deds k - Thu May 7 02:25:33 2009 - - 2 Answers - 0 Comments
Q. with corresponding output like: token output stack (bottom to up) --- --- --- i would appreciate if comments included. thanks, i'll give you best answer..
Asked by deds k - Thu May 7 02:25:33 2009 - - 2 Answers - 0 Comments
what is infix and postfix in c programming??
Q. what is infix and postfix in c?? pls. give me some example of it. pls. show me the source code (T_T) thnx..
Asked by Ron - Wed Sep 3 02:34:20 2008 - - 1 Answers - 0 Comments
A. Infix: int a = (7 + 3) / 2; That line declares an integer named "a" and sets it equal to 2. Nothing major here. The infix notations are the "+" and "/". They are in-fix because they are in the midst of the formula itself. It requires arguments on either side of it. You couldn't just say "43 +". There has to be something after the "+" or it makes no sense. We are used to this with everyday algebra. Postfix: int b = 5;//declares an integer and sets it to 5 int a = b++; //declares another integer, sets it equal to b. Then, it increments b by one. The ++ is postfix notation. A very common way to see this is in counting; something we do a lot of in programming. To count, we often increment a variable by one. In many languages you… [cont.]
Answered by Michael F - Wed Sep 3 03:41:52 2008
Q. what is infix and postfix in c?? pls. give me some example of it. pls. show me the source code (T_T) thnx..
Asked by Ron - Wed Sep 3 02:34:20 2008 - - 1 Answers - 0 Comments
A. Infix: int a = (7 + 3) / 2; That line declares an integer named "a" and sets it equal to 2. Nothing major here. The infix notations are the "+" and "/". They are in-fix because they are in the midst of the formula itself. It requires arguments on either side of it. You couldn't just say "43 +". There has to be something after the "+" or it makes no sense. We are used to this with everyday algebra. Postfix: int b = 5;//declares an integer and sets it to 5 int a = b++; //declares another integer, sets it equal to b. Then, it increments b by one. The ++ is postfix notation. A very common way to see this is in counting; something we do a lot of in programming. To count, we often increment a variable by one. In many languages you… [cont.]
Answered by Michael F - Wed Sep 3 03:41:52 2008
how to convert infix to postfix?
Q. in turbo C programming, how do you convert infix to postfix???thx!!
Asked by dan_abogado - Sat Sep 6 00:28:53 2008 - - 1 Answers - 0 Comments
A. Heres the code: #include #include #include #define oper(x) (x=='+' || x=='-' || x=='*' || x=='/') char in[30], post[30], stack[30]; int top=-1; void push(char x) { stack[++top]=x; } char pop() { return stack[top--]; } int precedence(char c) { if (c=='+' || c=='-') return 1; if (c=='*' || c=='/') return 2; if (c=='(') return 3; } main() { char c; int l,i,j=0,st1[20],k,h,f,eva l,s,N; printf("Enter the infix expression : "); scanf("%s",&in); l=strlen(in); for(i=0;i<=l;i++) { if(oper(in[i])) { post[j++]=' '; while(precedence(in[i])
Q. in turbo C programming, how do you convert infix to postfix???thx!!
Asked by dan_abogado - Sat Sep 6 00:28:53 2008 - - 1 Answers - 0 Comments
A. Heres the code: #include
[cont.]
Answered by Emperor Harsh, the great - Sat Sep 6 10:00:53 2008
What is the postfix form of the infix expression A*B+(C-D/F)?
Q. I got the answer to be ABC*+D-E/F*, i am confused when the scanning reaches the ..D/F.. PART
Asked by gejopal - Fri Mar 13 14:43:02 2009 - - 1 Answers - 0 Comments
Q. I got the answer to be ABC*+D-E/F*, i am confused when the scanning reaches the ..D/F.. PART
Asked by gejopal - Fri Mar 13 14:43:02 2009 - - 1 Answers - 0 Comments
I need Infix to Postfix in C. can any one give me its code?
Q. infix: 4*5-2 postfix: 45*2-
Asked by mohammad Taheri - Mon Jun 12 12:47:49 2006 - - 2 Answers - 0 Comments
A. Try Planet Source Code. Below is a link that has several examples:
Answered by Tim - Mon Jun 12 16:49:51 2006
Q. infix: 4*5-2 postfix: 45*2-
Asked by mohammad Taheri - Mon Jun 12 12:47:49 2006 - - 2 Answers - 0 Comments
A. Try Planet Source Code. Below is a link that has several examples:
Answered by Tim - Mon Jun 12 16:49:51 2006
Transform each of the following expressions to prefix and postfix?
Q. 5.Transform each of the following expressions to prefix and postfix? 1)(a+b)*(c-d)/e*f 2)(a+b)*(c/(d-e)+f)-g 1 6)Transform in to 1)prefix to infix and postfix i)+-abc ii)+a-bc 2 2)postfix to infix and prefix i)ab+c- ii)abc+-c 2
Asked by Venkatesh S - Sun Sep 9 06:25:30 2007 - - 1 Answers - 0 Comments
A. To get these right, I find it helps to draw the parse tree and then just "walk" it in the specified order. #1: (a+b)*(c-d)/e*f postfix: a b + c d - e f * / * prefix: * + a b / - c d * e f #2: 2)(a+b)*(c/(d-e)+f)-g 1 [I'll ignore the "1" at the end because it isn't legal in the infix expression.] (a+b)*(c/(d-e)+f)-g postfix: a b + c d e - f + / g - * prefix: * + a b - / c + - d e f g #3: +-abc infix: (a-b)+c postfix: a b - c + #4: +a-bc 2 [This isn't a legal prefix expression, so I'll ignore the trailing "2"] +a-bc 2 infix: a + (b - c) postfix: a b c - + #5: ab+c- infix: (a + b) - c prefix: - + a b c #6: abc+-c 2 [This is not a legal postfix expression. After the "-", all the operands and operators are exhausted, leaving… [cont.]
Answered by morgan - Tue Sep 11 14:12:09 2007
Q. 5.Transform each of the following expressions to prefix and postfix? 1)(a+b)*(c-d)/e*f 2)(a+b)*(c/(d-e)+f)-g 1 6)Transform in to 1)prefix to infix and postfix i)+-abc ii)+a-bc 2 2)postfix to infix and prefix i)ab+c- ii)abc+-c 2
Asked by Venkatesh S - Sun Sep 9 06:25:30 2007 - - 1 Answers - 0 Comments
A. To get these right, I find it helps to draw the parse tree and then just "walk" it in the specified order. #1: (a+b)*(c-d)/e*f postfix: a b + c d - e f * / * prefix: * + a b / - c d * e f #2: 2)(a+b)*(c/(d-e)+f)-g 1 [I'll ignore the "1" at the end because it isn't legal in the infix expression.] (a+b)*(c/(d-e)+f)-g postfix: a b + c d e - f + / g - * prefix: * + a b - / c + - d e f g #3: +-abc infix: (a-b)+c postfix: a b - c + #4: +a-bc 2 [This isn't a legal prefix expression, so I'll ignore the trailing "2"] +a-bc 2 infix: a + (b - c) postfix: a b c - + #5: ab+c- infix: (a + b) - c prefix: - + a b c #6: abc+-c 2 [This is not a legal postfix expression. After the "-", all the operands and operators are exhausted, leaving… [cont.]
Answered by morgan - Tue Sep 11 14:12:09 2007
Write a program that inputs infix expression the outputs postfix expression?
Q. please help
Asked by litol_twilky - Sun Aug 12 20:16:47 2007 - - 2 Answers - 0 Comments
A. in which language?
Answered by i_am_the_next_best_one - Mon Aug 13 05:56:36 2007
Q. please help
Asked by litol_twilky - Sun Aug 12 20:16:47 2007 - - 2 Answers - 0 Comments
A. in which language?
Answered by i_am_the_next_best_one - Mon Aug 13 05:56:36 2007
assembly program. infix to postfix and evaluating the result.?
Q. Hi. any1 has the code plz?!!
Asked by M_Gh - Fri May 29 02:39:04 2009 - - 1 Answers - 0 Comments
A. For assembly language help you need to at the very least specify what CPU or family of CPUs you are working with.
Answered by unknown - Fri May 29 06:00:29 2009
Q. Hi. any1 has the code plz?!!
Asked by M_Gh - Fri May 29 02:39:04 2009 - - 1 Answers - 0 Comments
A. For assembly language help you need to at the very least specify what CPU or family of CPUs you are working with.
Answered by unknown - Fri May 29 06:00:29 2009
Infix to postfix conversion?
Q. Can anyone help me how this program execute? import java.io.*; class StackX { private int maxSize; private char[] stackArray; private int[] stackArray1; private int top; public StackX(int s) { maxSize = s; stackArray = new char[maxSize]; top = -1; } public void push(char j) { stackArray[++top] = j; } public void push1(int j) { stackArray1[++top] =j; } public char pop() { return stackArray[top--]; } public char peek() { return stackArray[top]; } public boolean isEmpty() { return (top == -1); } public int size() { return top+1; } public char peekN(int n) { return stackArray[n]; } } class InToPost { private StackX theStack; private String input; private String output = ""; public InToPost(String in) { input = in; int stackSize =… [cont.]
Asked by Toyamah - Mon Mar 9 05:36:34 2009 - - 1 Answers - 0 Comments
A. import java.io.*; /**This is a stack storage*/ class StackX { private int maxSize; private char[] stackArray; private int[] stackArray1; private int top; /**Constructs the stact with size s*/ public StackX(int s) { maxSize = s; stackArray = new char[maxSize]; top = -1; } /**Pushes a character on the top of the stack*/ public void push(char j) { stackArray[++top] = j; } /**Pushes an integer on the top of the stack*/ public void push1(int j) { stackArray1[++top] =j; } /**Gets the top most character of the stack*/ public char pop() { return stackArray[top--]; } /**Peeks the top most of the stack*/ public char peek() { return stackArray[top]; } /**Checks if stack is empty*/ public boolean isEmpty() { return (top == -1); } /**Gives the… [cont.]
Answered by jerriel - Mon Mar 9 07:03:31 2009
Q. Can anyone help me how this program execute? import java.io.*; class StackX { private int maxSize; private char[] stackArray; private int[] stackArray1; private int top; public StackX(int s) { maxSize = s; stackArray = new char[maxSize]; top = -1; } public void push(char j) { stackArray[++top] = j; } public void push1(int j) { stackArray1[++top] =j; } public char pop() { return stackArray[top--]; } public char peek() { return stackArray[top]; } public boolean isEmpty() { return (top == -1); } public int size() { return top+1; } public char peekN(int n) { return stackArray[n]; } } class InToPost { private StackX theStack; private String input; private String output = ""; public InToPost(String in) { input = in; int stackSize =… [cont.]
Asked by Toyamah - Mon Mar 9 05:36:34 2009 - - 1 Answers - 0 Comments
A. import java.io.*; /**This is a stack storage*/ class StackX { private int maxSize; private char[] stackArray; private int[] stackArray1; private int top; /**Constructs the stact with size s*/ public StackX(int s) { maxSize = s; stackArray = new char[maxSize]; top = -1; } /**Pushes a character on the top of the stack*/ public void push(char j) { stackArray[++top] = j; } /**Pushes an integer on the top of the stack*/ public void push1(int j) { stackArray1[++top] =j; } /**Gets the top most character of the stack*/ public char pop() { return stackArray[top--]; } /**Peeks the top most of the stack*/ public char peek() { return stackArray[top]; } /**Checks if stack is empty*/ public boolean isEmpty() { return (top == -1); } /**Gives the… [cont.]
Answered by jerriel - Mon Mar 9 07:03:31 2009
Convert infix to postfix: y = (a*b) + (c/d)?
Q. I don't really have trouble solving it but do the parenthesizes get pushed onto the stack? and if so, how do i solve it. so are the parenthesizes ignored?
Asked by love is blind - Wed Nov 19 17:34:02 2008 - - 1 Answers - 0 Comments
A. One advantage of postfix is that there are no parenthesis. The expression you seek is a b * c d / +
Answered by jgoulden - Wed Nov 19 17:38:47 2008
Q. I don't really have trouble solving it but do the parenthesizes get pushed onto the stack? and if so, how do i solve it. so are the parenthesizes ignored?
Asked by love is blind - Wed Nov 19 17:34:02 2008 - - 1 Answers - 0 Comments
A. One advantage of postfix is that there are no parenthesis. The expression you seek is a b * c d / +
Answered by jgoulden - Wed Nov 19 17:38:47 2008
write a program that converts a postfix expression to infix using pushdown stack?in C++ pleas?
Q. plz i need it today
Asked by Nourah - Fri Nov 30 12:58:58 2007 - - 1 Answers - 0 Comments
Q. plz i need it today
Asked by Nourah - Fri Nov 30 12:58:58 2007 - - 1 Answers - 0 Comments
How do you construct a binary tree when its infix and prefix traversals are given to you??
Q. Or i would like to know how to construct the postfix traversal form, given the infix and prefix notations...
Asked by archu - Fri Nov 23 11:41:31 2007 - - 1 Answers - 0 Comments
A. given an infix a+b-c and a prefix +a-bc start with prefix first letter is + make + as root node tree + now goto a, a is to the left of + in infix so add a as left child of + tree + / a now - is next in prefix ok so add - but - is right of + so add - to right child of + so + / \ a - now do the same for b ,c b is left of - c is right of - in infix so we get + / \ a - / \ b c this is binary tree to get postfix order do LRN traversing first left child then right child then the current child so u get for the above tree abc-+
Answered by heyyy - Fri Nov 23 13:30:24 2007
Q. Or i would like to know how to construct the postfix traversal form, given the infix and prefix notations...
Asked by archu - Fri Nov 23 11:41:31 2007 - - 1 Answers - 0 Comments
A. given an infix a+b-c and a prefix +a-bc start with prefix first letter is + make + as root node tree + now goto a, a is to the left of + in infix so add a as left child of + tree + / a now - is next in prefix ok so add - but - is right of + so add - to right child of + so + / \ a - now do the same for b ,c b is left of - c is right of - in infix so we get + / \ a - / \ b c this is binary tree to get postfix order do LRN traversing first left child then right child then the current child so u get for the above tree abc-+
Answered by heyyy - Fri Nov 23 13:30:24 2007
c++ programme code for infix expressions to postfix expression with stack and also evalute the expression?
Q. c++ programme code for infix expressions to postfix expression with stack and also evalute the expression?
Asked by Mofazzol H - Mon Oct 9 02:39:30 2006 - - 1 Answers - 0 Comments
A. The following code contains no error checking and doesn't handle unary operators. struct OP { char op; char rank; }; stack opstack; stack vstack; char rank(char op) { switch (op) { case '+': case '-': return 1; case '*': case '/': return 2; case '^': return 3; default: return 0; } } inline char popop() { char op = opstack.top().op; opstack.pop(); return op; } inline double popv() { double v = vstack.top(); vstack.pop(); return v; } void doTheMath() { double r = 0; charop; doublev1, v2; op = popop(); v2 = popv(); v1 = popv(); switch(op) { case '+': r = v1 + v2; break; case '-': r = v1 - v2; break; case '*': r = v1 * v2; break; case '/': r = v1 / v2; break; case '^': r = pow(v1, v2); break; default: r = 0; break; }… [cont.]
Answered by Will - Mon Oct 9 16:17:11 2006
Q. c++ programme code for infix expressions to postfix expression with stack and also evalute the expression?
Asked by Mofazzol H - Mon Oct 9 02:39:30 2006 - - 1 Answers - 0 Comments
A. The following code contains no error checking and doesn't handle unary operators. struct OP { char op; char rank; }; stack
Answered by Will - Mon Oct 9 16:17:11 2006
write a stack program that inputs infix expression the outputs postfix expression?
Q. for example (6+9-2)*5/2, its output is 69+2-5*2/
Asked by litol_twilky - Thu Aug 9 20:40:25 2007 - - 1 Answers - 0 Comments
A. It's easy to do this with a stack -- just match parenthesis and pust to the stack based on order of ops
Answered by mdigitale - Thu Aug 9 20:43:03 2007
Q. for example (6+9-2)*5/2, its output is 69+2-5*2/
Asked by litol_twilky - Thu Aug 9 20:40:25 2007 - - 1 Answers - 0 Comments
A. It's easy to do this with a stack -- just match parenthesis and pust to the stack based on order of ops
Answered by mdigitale - Thu Aug 9 20:43:03 2007
If it is easier to solve with infix notation, why would anyone want to use postfix or prefix notations?
Q. If it is easier to solve with infix notation, why would anyone want to use postfix or prefix notations?
Asked by kevin y - Wed Aug 8 05:12:39 2007 - - 1 Answers - 0 Comments
A. umm not really. its actually easier to solve mathematical equations in prefix notation. The reason being that when we are coding the same, it helps to know what the operation is and optimize based on that Most mathematical operations are binary, that means that given a code like operation token1 token2 we can do something like this switch operation case + : add the next two tokens case - : subtract the 2nd token from the 1st case * : ... That would not be so easily possible if the operator was between the tokens, especially when there are brackets. With prefix, a simple stack would let you do the computation Things become even better when you use non binary math in a language like lisp, you dont hv to write 1+2+3+4 you can write (+… [cont.]
Answered by Neil - Wed Aug 8 05:46:50 2007
Q. If it is easier to solve with infix notation, why would anyone want to use postfix or prefix notations?
Asked by kevin y - Wed Aug 8 05:12:39 2007 - - 1 Answers - 0 Comments
A. umm not really. its actually easier to solve mathematical equations in prefix notation. The reason being that when we are coding the same, it helps to know what the operation is and optimize based on that Most mathematical operations are binary, that means that given a code like operation token1 token2 we can do something like this switch operation case + : add the next two tokens case - : subtract the 2nd token from the 1st case * : ... That would not be so easily possible if the operator was between the tokens, especially when there are brackets. With prefix, a simple stack would let you do the computation Things become even better when you use non binary math in a language like lisp, you dont hv to write 1+2+3+4 you can write (+… [cont.]
Answered by Neil - Wed Aug 8 05:46:50 2007
Why computers prefer and use Postfix expressions instead of prefix expressions??
Q. We all know computers convert all infix arihmetic expressions to postfix and then evaluate them.. but why we use and prefer postfix over prefix expressions?
Asked by Jublee - Tue Sep 26 13:42:21 2006 - - 3 Answers - 0 Comments
A. i think implementation of code for sloving postfix expression is easier and solving postfix expressions is much more faster & efficient then solving prefix expressions.
Answered by Digitally ! - Wed Sep 27 14:05:36 2006
Q. We all know computers convert all infix arihmetic expressions to postfix and then evaluate them.. but why we use and prefer postfix over prefix expressions?
Asked by Jublee - Tue Sep 26 13:42:21 2006 - - 3 Answers - 0 Comments
A. i think implementation of code for sloving postfix expression is easier and solving postfix expressions is much more faster & efficient then solving prefix expressions.
Answered by Digitally ! - Wed Sep 27 14:05:36 2006
From Yahoo Answer Search: 'postfix to infix'
Mon Nov 23 06:13:08 2009 [ refresh local cache ]