# Tag Archives: Quick Sort

## Quickselect AlgorithmNovember 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 »

## Dual pivot QuicksortSeptember 19, 2017

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 »

## Positive elements at even and negative at odd positionsSeptember 12, 2017

You have been given an array and you have to make a program to convert that array such that positive elements occur at even numbered… Read More »

## Move all negative numbers to beginning and positive to end with constant extra spaceSeptember 6, 2017

An array contains both positive and negative numbers in random order. Rearrange the array elements so that all negative numbers appear before all Examples: Input… Read More »

## Why quicksort is better than mergesort ?July 21, 2017

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 »

## Hoare’s vs Lomuto partition scheme in QuickSortFebruary 6, 2017

We have discussed implementation of QuickSort using Lomuto partition scheme. Lomuto’s partition scheme is easy to implement as compare to Hoare scheme. Lomuto’s Partition Scheme… Read More »

## Know Your Sorting Algorithm | Set 2 (Introsort- C++’s Sorting Weapon)June 26, 2016

We have discussed sorting weapons used by different languages in previous article. In this article, C++’s Sorting Weapon, Introsort is discussed. What is Introsort? Simply… Read More »

## Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages)

Ever wondered how sort() function we use in C++/Java or sorted() in Python work internally? Here is a list of all the inbuilt sorting algorithms… Read More »

## C qsort() vs C++ sort()June 4, 2016

Standard C library provides qsort function that can be used for sorting an array. Following is the prototype of qsort() function. // Sort an array… Read More »

## QuickSort Tail Call Optimization (Reducing worst case space to Log n )March 30, 2016

In QuickSort, partition function is in-place, but we need extra space for recursive function calls. A simple implementation of QuickSort makes two calls to itself… Read More »

## Tail Call EliminationMarch 29, 2016

We have discussed (in tail recursion) that a recursive function is tail recursive if recursive call is the last thing executed by the function. We… Read More »

## 3-Way QuickSort (Dutch National Flag)August 27, 2015

In simple QuickSort algorithm, we select an element as pivot, partition the array around pivot and recur for subarrays on left and right of pivot.

## Why Quick Sort preferred for Arrays and Merge Sort for Linked Lists?May 16, 2015

Why is Quick Sort preferred for arrays? Below are recursive and iterative implementations of Quick Sort and Merge Sort for arrays.

## Can QuickSort be implemented in O(nLogn) worst case time complexity?January 29, 2015

The worst case time complexity of a typical implementation of QuickSort is O(n2). The worst case occurs when the picked pivot is always an extreme… Read More »

## Nuts & Bolts Problem (Lock & Key problem) | Set 1December 20, 2014

Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping between nuts and bolts. Match… Read More »