We discussed Insertion sort in detail earlier. This post shows the recursive implementation of Insertion Sort. Continue reading »

May 282017

May 282017

May 172017

It is used when there are few unique elements in an array. Counting sort takes O(n+k) time in the worst case, where n is number of elements and all the elements are in the range 1 to k (both inclusive). Continue reading »

Mar 102015

Given a sorted array of integers, find a “popular” element i.e. one which occurs more than n/4 times. If no such element exist (which occurs more than n/4 times) then print error.

For example: If Input array has 8 elements as below {1, 3, 3, 3, 4, 6, 9, 10} Then 3 is the popular element that comes three times.

Jul 152013

Insertion sort is the most common sorting technique used by card players to sort their cards. It sorts the array in-place and is the one of the best comparison sort algorithms. Continue reading »