# Data Structure

## 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.

## Reverse a Linked List in Group of Given size

Reverse the given Linked List is Group of given size K using recursion (recursively) and without recursion (iteratively).

Linked List can be reversed both recursively and iteratively. Reverse a Linked List using recursion. Reverse a Linked List using iteration.

## Binary Tree Level Order Traversal

Given a Binary Tree, print level order traversal. Example, Input Binary Tree Output 10 5 20 4 8 15 25 Algorithm We will discuss two ways to print the level order traversal of the binary tree. Both use queue and are very similar. Level Order Traversal Using Queue First Approach As we know, queue follows …

## 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.

## Queue

Queue is a linear data structure. It follows First In First Out (FIFO). In other words, the item which is inserted first is accessed/deleted first. For example, when you go to cashier in a mall, then the person first in line is served first. This is a queue. Basic Operations:- enqueue/push: Insert item in the …

## 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 …