## How to sort an array in descending order using sort() in c++?

The C++ STL function sort() by default sorts the array in ascending order. If we want to sort array in descending order using sort(), we need to use a Comparator Function. Syntax Sort Array in Descending Order Using sort() We can use the inbuilt greater<type>() function to arrange array in descending order. greater<type>() compares the …

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

## Binary Search

Binary search is algorithm that searches an element in a sorted array in O(logN) complexity. It can be implemented using recursion or without recursion.

## How to run a Java program?

Make sure you have correctly set up the Java Runtime Environment before attempting to run the java program.

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