Dsa
Stack
Medium
Infix to Postfix Conversion
Write a program that converts an infix expression (containing single-digit integers and operators +, -, *, /) into its postfix notation. Assume that the input is always valid. Parentheses can also be included to group expressions.
Input
A single line containing the infix expression.
Output
Print the postfix expression as a single line with tokens separated by spaces.
Example
Input:
3 + 4 * 2 / ( 1 - 5 )
Output:
3 4 2 * 1 5 - / +
Key concepts
stackshunting-yardconversion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now