## Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest, ..

Given an array of integers, task is to print the array in the order – smallest number, Largest number, 2nd smallest number, 2nd largest number,… Read More »

Quick Links for Sorting

Sorting Terminology |

Stability in sorting algorithms |

Time Complexities of all Sorting Algorithms |

External Sorting |

Given an array of integers, task is to print the array in the order – smallest number, Largest number, 2nd smallest number, 2nd largest number,… Read More »

Given an array of size n, the goal is to find out the smallest number that is repeated exactly ‘k’ times where k > 0?… Read More »

Given an array of items, an i-th index element denotes the item id’s and given a number m, the task is to remove m elements… Read More »

Previous article of this segment dealt with sorting list of dictionaries by values using lambda function. Ways to sort list of dictionaries by values in… Read More »

Write a SortedMerge() function that takes two lists, each of which is unsorted, and merges the two together into one new list which is in… Read More »

Given an array of size n and a number k, we need to print first k natural numbers that are not there in given array.… Read More »

Given an array of integers, sort the array according to frequency of elements. If frequencies of two elements are same, print them in increasing order.… Read More »

This a common question asked in DS interviews that despite of better worst case performance of merge sort, quicksort is considered better than mergesort. There… Read More »

Given a singly linked list containing n nodes. The problem is to sort the list using recursive selection sort technique. The approach should be such… Read More »

Here is a C++ code that illustrates that sorting the data miraculously makes the code faster than the unsorted version. Let’s try out a sample… Read More »

Sort the given biotonic doubly linked list. A biotonic doubly linked list is a doubly linked list which is first increasing and then decreasing. A… Read More »

Sort the doubly linked list using insertion sort technique. Initial doubly linked list Doubly Linked List after applying insertion sort Recommended: Please try your approach… Read More »

Given four sorted arrays each of size n of distinct elements. Given a value x. The problem is to count all quadruples(group of four numbers)… Read More »

Given an array A[] of n integers, the task is to find a subsequence of size k whose product is maximum among all possible k… Read More »

Given an array of both positive and negative numbers, the task is to find out the subarray whose sum is closest to 0. There can… Read More »