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 <[email protected]>wrote: > oh bhai mere..... kewal preorder use karke kaise tree bana dega??? > > > On Fri, Jun 29, 2012 at 11:23 PM, amrit harry <[email protected]>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 < >> [email protected]> 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 < >>> [email protected]> 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 [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> 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 [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
