i think this algo will do... reverse the given prefix expression while(!nd of input) { if it is operand push in a stack if its an operator { op1=pop(stack); op2=pop(stack); push (op1 op2 operator) on to stack; } } On Sat, Jun 30, 2012 at 1:56 AM, Bhaskar Kushwaha < bhaskar.kushwaha2...@gmail.com> wrote:
> example > -+53+2/36 > step 1: 63/2+35+- > step 2: 36/2+53+- > > On Sat, Jun 30, 2012 at 1:55 AM, Bhaskar Kushwaha < > bhaskar.kushwaha2...@gmail.com> wrote: > >> reverse the prefix notation and then reverse each continuous occurence of >> operands >> >> >> On Sat, Jun 30, 2012 at 12:50 AM, Abhishek Sharma >> <abhi120...@gmail.com>wrote: >> >>> convert prefix to infix,then convert infix to postfix.Now, to convert >>> prefix to infix, push numbers in one stack and operators in other.Then use >>> this<http://www.velocityreviews.com/forums/t445633-prefix-to-infix-conversion.html> >>> algo >>> to perform this.Then do the same for infix to postfix.It works with simple >>> operators,but difficult to implement with parenthesis. >>> >>> >>> On Sat, Jun 30, 2012 at 12:21 AM, rahul ranjan < >>> rahul.ranjan...@gmail.com> wrote: >>> >>>> oh bhai mere..... kewal preorder use karke kaise tree bana dega??? >>>> >>>> >>>> On Fri, Jun 29, 2012 at 11:23 PM, amrit harry >>>> <dabbcomput...@gmail.com>wrote: >>>> >>>>> @bhaskar ur algo fails on this case (5+3)-(2+(3/6)) >>>>> -+53+2/36 >>>>> 63/2+35-+ >>>>> showing that 6/3 but actually it is 3/6 >>>>> so i think it could be done by folowing algo >>>>> make a binary tree of given expression in O(n) then do postorder >>>>> traversal take O(n) so problem can be solved in O(n). and take O(2*n+1) >>>>> space >>>>> >>>>> On Fri, Jun 29, 2012 at 9:13 PM, Bhaskar Kushwaha < >>>>> bhaskar.kushwaha2...@gmail.com> wrote: >>>>> >>>>>> I think just reversing the prefix notation converts it to postfix >>>>>> notation >>>>>> >>>>>> >>>>>> On Fri, Jun 29, 2012 at 7:46 PM, Gobind Kumar Hembram < >>>>>> gobind....@gmail.com> wrote: >>>>>> >>>>>>> Given an integer expression in a prefix format (i.e. the operator >>>>>>> precedes the number it is operating on) , print the expression in >>>>>>> the >>>>>>> post fix format . >>>>>>> >>>>>>> Example: If the integer expression is in the prefix format is >>>>>>> *+56-78, >>>>>>> the postfix format expression is 56+78-*. Both of these >>>>>>> correspond to the expression (5+6)*(7-8). >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Algorithm Geeks" group. >>>>>>> To post to this group, send email to algogeeks@googlegroups.com. >>>>>>> To unsubscribe from this group, send email to >>>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> regards, >>>>>> Bhaskar Kushwaha >>>>>> Student >>>>>> Final year >>>>>> CSE >>>>>> M.N.N.I.T. Allahabad >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Algorithm Geeks" group. >>>>>> To post to this group, send email to algogeeks@googlegroups.com. >>>>>> To unsubscribe from this group, send email to >>>>>> algogeeks+unsubscr...@googlegroups.com. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks & Regards >>>>> Amritpal singh >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to algogeeks@googlegroups.com. >>>>> To unsubscribe from this group, send email to >>>>> algogeeks+unsubscr...@googlegroups.com. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to algogeeks@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> Abhishek Sharma >>> Under-Graduate Student, >>> PEC University of Technology >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> regards, >> Bhaskar Kushwaha >> Student >> Final year >> CSE >> M.N.N.I.T. Allahabad >> >> > > > -- > regards, > Bhaskar Kushwaha > Student > Final year > CSE > M.N.N.I.T. Allahabad > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.