# Stack

## Infix to Prefix

In this article, we will discuss how to convert infix expression to prefix expression using stack. Infix Expression: Infix expressions are in form Operand Operator Operand. Example, a + b. Prefix Expression: Prefix expressions are in form Operator Operand Operand. Example, + a b. For example, Input Prefix Expression: A + ( B * C …

## C/C++ Program to find factorial using stack

Write a program to find factorial using stack in c/c++. Example, Input: 5 Output: 120 For this tutorial, we will implement our own stack. If you are using C++ then you may use the inbuilt stack. Method 1 To calculate the factorial of a number N without a stack, we use a temporary variable and …

## Program to Reverse Stack Using Queue

Reverse Stack Using Queue. Pop stack and push all the elements to a queue. Then pop queue and push all the elements back to the stack.

## Prefix To Infix

Prefix to Infix Conversion. Algorithm to convert Prefix to Infix. using Stack. Read Prefix Expression from right-to-left, in reverse order.

## Evaluation of Prefix Expressions (Polish Expressions)

Evaluation of Prefix Expression is faster than an Infix Expression. This is because Prefix Expression has no parenthesis or precedence rules.

## Difference Between Stack and Queue

The main difference a stack and queue is stack follows Last in First Out (FIFO) whereas queue follows First In First Out (FIFO) principle.

## Postfix to Infix

We can convert any postfix expression to infix expression using stack in one pass. Example Input: abc^d/e*+ Output: (a+(((b^c)/d)*e)) Postfix to Infix Algorithm Steps Initialize an empty stack. Scan postfix expression from left to right. If the scanned character is an operand, push it to the stack. If the scanned character is an operator, Pop …

## Evaluation of Postfix Expression Using Stack

In order to solve a complex expression, we first convert the expression from infix to postfix. This is done because the evaluation of postfix expression does not involve parenthesis. Evaluation of postfix expression can be easily done using stack. Algorithm Initialize an empty stack. Scan postfix expression from left to right. If the scanned character …

## Infix to Postfix

We will study how we can convert infix expression to postfix expression using stack. Infix Expression Infix Expression is in the form of Operand Operator Operand.For example, 4 + 5. Postfix Expression ( or Reverse Polish Notation ) Postfix Expression is in form Operand Operand Operator.For example, 4 5 +. Before moving ahead we must …

## Stack

A stack is a linear data structure. Stack follows Last In First Out (LIFO). This means that the item which is inserted most recently will be accessed first.