Sorting algorithm interview questions

Sorting algorithms: Technical interviews must-know

Sorting algorithms are a must-know for any technical interview, be it a startup or a FANG company like Facebook, Amazon. If you fail to explain the sorting algorithm you are ...
Read More

Arrays With Elements In The Range 1 to N

When an array has all its elements in the range of 1 to N ( where N is the length of the array ) we can use the indices to ...
Read More

Inversions in array

Inversions in array Let A[0…n – 1] be an array of n distinct positive integers. If i < j and A[i] > A[j] then the pair (i, j) is called an ...
Read More

Dutch National Flag Problem

Dutch National Flag Problem Given an array with 0s,1s and 2s, sort array in increasing order. Another way to phrase this problem is sort balls with three different colors : ...
Read More

3-way quicksort (Quick sort on non unique elements)

In the post on the Dutch National Flag Algorithm, we discussed how to sort an array in linear time by partitioning it in four parts, red, white, unknown and blue ...
Read More

Merge sort algorithm

Merge Sort Algorithm We can classify sorting algorithms based on their complexity, selection sort, bubble, and insertion sort have the complexity of O(n2) while heap sort, merge sort and quick ...
Read More

Group Anagrams

Many a times we need to sort some things which are not integers, foremost being strings. How do we go about using quicksort? I did not know that the C ...
Read More

Merge two sorted linked lists

Problem statement is simple: Merge two sorted linked lists, without using extra space. To refer to the basics of linked list, please follow the post : Linked list data structure ...
Read More

Quick sort algorithm

Quick sort Algorithm Quicksort like merge sort is a sorting algorithm under divide and conquer paradigm of algorithms like merge sort. The basic idea of the algorithm is to divide ...
Read More

Count sort : Sorting in linear time

Count sort : Sorting in linear time Are there any sorting algorithm which has worst case complexity of O(n)? There are a few like count sort and decision tree algorithms ...
Read More