## Print n smallest elements from given array in their original order

We are given an array of m-elements, we need to find n smallest elements from the array but they must be in the same order… Read More »

Quick Links for Sorting

Sorting Terminology |

Stability in sorting algorithms |

Time Complexities of all Sorting Algorithms |

External Sorting |

We are given an array of m-elements, we need to find n smallest elements from the array but they must be in the same order… Read More »

Given a linked list containing n nodes. The problem is to rearrange the nodes of the list in such a way that the data in… Read More »

In this program, we need to accept a list and sort it based on the length of the elements present within. Examples: Input : list… Read More »

Given an array of n-elements. Given array is a permutation of some Arithmetic Progression. Find the minimum number of De-arrangements present in that array so… Read More »

Given an array and two numbers x and k. Find the number of different ordered pairs of indexes (i, j) such that a[j] >= a[i]… Read More »

Given two same sized arrays A[] and B[] (both arrays contain distinct elements individually but may have some common elements), task is to form a… Read More »

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 »

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 »

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 »

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 »

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 »

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 »

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 »