Write an algorithm to show the postfix expression with the input given as : a b + c d +*f ? .



Write an algorithm to show the postfix expression with the input given as : a b + c d +*f ? ...

Answer / Anil Tomar

Algorithm: Postfix Evaluation
1. Create an empty stack s.
2. Iterate through each character in the postfix expression:n a) If the character is an operand, push it onto the stack.n b) If the character is an operator, pop two operands from the stack, apply the operator on them, and push the result back to the stack.n c) If the character is a left parenthesis '(', push it onto the stack.n d) If the character is a right parenthesis ')', pop operands from the stack until a matching left parenthesis is found and discard both.
3. The final value on the stack is the result of the postfix expression.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What is dynamic array in excel?

1 Answers  


What is the difference between Array and LinkedList?

1 Answers  


do records fall under linear or non linear data structures?

1 Answers  


For the following COBOL code, draw the Binary tree? 01 STUDENT_REC. 02 NAME. 03 FIRST_NAME PIC X(10). 03 LAST_NAME PIC X(10). 02 YEAR_OF_STUDY. 03 FIRST_SEM PIC XX. 03 SECOND_SEM PIC XX.

0 Answers  


Can array store heterogeneous data?

1 Answers  


When should structures be passed by values or by reference?

1 Answers   Tech Mahindra,


What is a postfix expression?

1 Answers  


What is a hashers run?

1 Answers  


Does treeset remove duplicates?

1 Answers  


What is the Difference between treemap and hashmap?

1 Answers  


What is difference between list and array list?

1 Answers  


How efficient is bubble sort?

1 Answers  


Categories