I think I figured out a solution. Please correct me if I missed anything. *Example:* Input: ((A+B)*C) Expected output: (A+B)*C
*Assumptions:* - Peek (queue) just tells the element in front end of queue without deleting it. - precedence( ) is a function which looks a precedence table of operators *Pseudo code below:* 1) Convert infix expression to postfix AB+C* 2) Insert only operators in queue 'Q' (front)+ -------- *(rear) 3) Parse postfix expression 4) If operand, push to stack 'S' 5) If operator 5.1) y=Delete(Q) 5.2) If precedence(y) > precedence(peek(Q)), then Push (S, "Pop(S) y Pop(S)") 5.3) If precedence(y) < precedence(peek(Q)), then Push (S, "( Pop(S) y Pop(S) )") 6) Final result on top of 'S' -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/RGom9z_GybEJ. 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.
