## Difference between highest and least frequencies in an array

Given an array, find the difference between highest occurrence and least occurrence of any number in an array Examples: Input : arr[] = [7, 8,… Read More »

Quick Links for Sorting

Sorting Terminology |

Stability in sorting algorithms |

Time Complexities of all Sorting Algorithms |

External Sorting |

Given an array, find the difference between highest occurrence and least occurrence of any number in an array Examples: Input : arr[] = [7, 8,… Read More »

Consider an infinite x-y plane. Infinite people walk on the plane in upward or +ve Y direction. At each integer point on the x-axis, only… Read More »

Given a binary array, sort it using one traversal and no extra space. Examples: Input : 1 0 0 1 0 1 0 1 1… Read More »

Given an array with n distinct elements. An array is said to be almost sorted (non-decreasing) if any of its elements can occurs maximum of… Read More »

Given an array of n positive integers that represent lengths. Find out the maximum possible area whose four sides are picked from given array. Note… Read More »

Print the elements of an array in the decreasing frequency if 2 numbers have same frequency then print the one which came first. Examples: Input… Read More »

As we know, the single pivot quick sort takes a pivot from one of the ends of the array and partitioning the array, so that… Read More »

As we know, Mergesort is a divide and conquer algorithm that splits the array to halves recursively until it reaches an array of the size… Read More »

As we know, selection sort algorithm takes the minimum on every pass on the array, and place it at its correct position. The idea is… Read More »

Given an array of n distinct elements and a number x, arrange array elements according to the absolute difference with x, i. e., element having… Read More »

Given an array of strings, print them in alphabetical (dictionary) order. If there are duplicates in input array, we need to print them only once.… Read More »

Given a linked list of 0s, 1s and 2s, sort it. Examples: Input : 2->1->2->1->1->2->0->1->0 Output : 0->0->1->1->1->1->2->2->2 Input : 2->1->0 Output : 0->1->2 Recommended:… Read More »

Given a grid of size n x len filled with lowercase characters. We can swap two adjacent characters in the same row and column. Now… Read More »

Implementation of Insertion Sort using STL functions. Pre-requisites : Insertion Sort, std::rotate, std::upper_bound, C++ Iterators. The idea is to use std::upper_bound to find an element… Read More »

Given an array of integers, sort the first half of the array in ascending order and second half in descending order. Examples: Input : arr[]… Read More »