Challenge - 5 Problems
Infix to Postfix Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this infix to postfix conversion?
Given the infix expression
A+B*C, what is the resulting postfix expression after conversion using a stack?DSA C
Input: A+B*C Output: ?
Attempts:
2 left
💡 Hint
Remember that multiplication (*) has higher precedence than addition (+).
✗ Incorrect
In infix to postfix conversion, operators with higher precedence are placed before lower precedence operators in postfix. So B*C is evaluated first, then added to A.
❓ Predict Output
intermediate2:00remaining
What is the postfix expression for this infix with parentheses?
Convert the infix expression
(A+B)*C to postfix using stack-based conversion. What is the output?DSA C
Input: (A+B)*C Output: ?
Attempts:
2 left
💡 Hint
Parentheses force the addition to happen before multiplication.
✗ Incorrect
Parentheses mean A+B is evaluated first, so in postfix it becomes AB+, then multiplied by C, so AB+C*.
❓ Predict Output
advanced2:30remaining
What is the postfix output of this complex infix expression?
Convert the infix expression
A+B*C-D/E to postfix using stack conversion. What is the correct postfix expression?DSA C
Input: A+B*C-D/E Output: ?
Attempts:
2 left
💡 Hint
Remember operator precedence: * and / before + and -, and left to right for same precedence.
✗ Incorrect
First B*C and D/E are evaluated, then added and subtracted accordingly. So postfix is ABC*+DE/-.
🔧 Debug
advanced3:00remaining
Identify the error in this infix to postfix conversion snippet
This C code snippet attempts to convert infix to postfix but produces wrong output. What is the main logical error?
DSA C
char stack[100]; int top = -1; void push(char c) { stack[++top] = c; } char pop() { return stack[top--]; } // Infix: A+B*C // Code pushes operators without checking precedence properly. // What is the error?
Attempts:
2 left
💡 Hint
Check how operator precedence affects when to pop from stack.
✗ Incorrect
The main error is not popping operators with higher or equal precedence before pushing a new operator, which breaks postfix order.
🧠 Conceptual
expert2:00remaining
What is the maximum stack size needed for converting an infix expression of length n?
Given an infix expression of length n (including operands, operators, and parentheses), what is the maximum number of elements that the operator stack can hold during infix to postfix conversion?
Attempts:
2 left
💡 Hint
Consider the worst case where all characters are operators or parentheses that stay on stack.
✗ Incorrect
In the worst case, all characters except operands could be operators or parentheses pushed onto the stack, so maximum size is n.
