# Category: Sorting

## Sort an array using one swap

Given an array where all its elements are sorted except two elements which were swapped, sort the array in linear time. Assume there are no duplicates in the array.

Read More Sort an array using one swap

## Quicksort using Dutch National Flag Algorithm

Implement Quicksort efficiently for inputs containing many repeated elements.     Quicksort exhibits poor performance for inputs that contain many repeated elements. The problem is clearly visible when all the input elements are equal. Then at each recursion, the left partition is empty (no input values are less than the pivot), and the right partition …

Read More Quicksort using Dutch National Flag Algorithm

## Merging Overlapping Intervals

Given a set of intervals, print all non-overlapping intervals after merging overlapping intervals.

Read More Merging Overlapping Intervals

## Merge two arrays by satisfying given constraints

Given two sorted arrays X[] and Y[] of size m and n each where m >= n and X[] has exactly n vacant cells, merge elements of Y[] in their correct position in array X[] i.e. merge (X, Y) by keeping the sorted order.

Read More Merge two arrays by satisfying given constraints

## Inplace merge two sorted arrays

Given two sorted arrays X[] and Y[] of size m and n each, merge elements of X[] with elements of array Y[] by maintaining the sorted order. i.e. fill X[] with first m smallest elements and fill Y[] with remaining elements. The conversion should be done in-place and without using any other data structure.

Read More Inplace merge two sorted arrays