##
stable_sort() in C++ STL
November 22, 2017

Like std::sort(), stable_sort also sorts an array. The syntax is also same. Output : Array after sorting using default sort is : 0 1 2… Read More »

Quick Links for Sorting

Sorting Terminology |

Stability in sorting algorithms |

Time Complexities of all Sorting Algorithms |

External Sorting |

November 22, 2017

Like std::sort(), stable_sort also sorts an array. The syntax is also same. Output : Array after sorting using default sort is : 0 1 2… Read More »

November 16, 2017

Given N boxes and their size in an array. You are allowed to keep a box inside another box only if the box in which… Read More »

November 15, 2017

Sorting using trivial hash function. Examples: Input : 9 4 3 5 8 Output : 3 4 5 8 9 We have read about various… Read More »

Given an array of length n + 1, containing elements 1 through n and a space, Requires the use of a given swap (index i,… Read More »

November 9, 2017

Given two numbers n and k, find an array containing values in [1, n] and requires exactly k calls of recursive merge sort function. Examples:… Read More »

November 7, 2017

Given an array of size N. Let A and B be the minimum and maximum in the array respectively. Task is to find how many… Read More »

November 5, 2017

Given an unsorted array of distinct elements. Task is to count number of cross lines formed in an array elements after sorting the array elements.… Read More »

A median in an array with the length of n is an element which occupies position number (n+1)/2 after we sort the elements in the… Read More »

November 4, 2017

Quickselect is a selection algorithm to find the k-th smallest element in an unordered list. It is related to the quick sort sorting algorithm. Examples:… Read More »

November 1, 2017

We are given N jobs numbered 1 to N. For each activity, let Ti denotes the number of days required to complete the job. For… Read More »

October 30, 2017

Given a string, sort it in descending order. Examples: Input : alkasingh Output : snlkihgaa Input : nupursingh Output : uusrpnnihg Input : geeksforgeeks Output… Read More »

October 27, 2017

Given an n x n matrix containing all the numbers in the range 0 to n2-1. The problem is to calculate the total energy required… Read More »

October 25, 2017

Given an array of positive and negative numbers, arrange them such that all negative integers appear before all the positive integers in the array without… Read More »

October 23, 2017

Given an array of n integers. We are allowed to add k additional integer in the array and then find the median of the resultant… Read More »

October 18, 2017

We are given two arrays. We need to sort one array according to another. Examples: Input : 2 1 5 4 9 3 6 7… Read More »