Write the algorithm for converting infix expression to postfix expression?
Answer / Sumeet Bhandari
1. Create a stack and an empty output string.
2. Traverse the input infix expression from left to right (inorder).
3. If the current character is an operand, append it to the output string.
4. If the current character is an operator, pop two operands from the stack and append the operator along with them in the reverse order to the output string. Perform the operation if necessary.
5. If the current character is a left parenthesis '(', push it onto the stack.
6. If the current character is a right parenthesis ')', pop operators from the stack and append them to the output string until a matching left parenthesis is found.
7. After traversing the entire infix expression, all remaining operands in the stack are popped and appended to the output string.
| Is This Answer Correct ? | 0 Yes | 0 No |
Can treemap have null values?
Explain the most efficient method to reverse a linked list?
What is Another name of Dynamically allocating memory.
What is sorting problem?
What are the types of linked list?
Which is better hashset or treeset?
Can we null keys in treemap?
What are the four types of variables?
What is the use of data structure in real life?
For which header list, the last node contains the null pointer?
Write a recursive c function to calculate the height of a binary tree.
Is hashtable throw concurrentmodificationexception?