Print the elements of an array in the decreasing frequency if 2 numbers have same frequency then print the one which came first.
Examples:
Input: arr[] = {2, 5, 2, ...

Share

Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n log k) time. For example, let us ...

Share

Prerequisite : Structures in C
Name and marks in different subjects (physics, chemistry and maths) are given for all students. The task is to compute total marks and ...

Share

Given a linked list of 0s, 1s and 2s, sort it.
Source: Microsoft Interview | Set 1
Recommended: Please solve it on “PRACTICE” first, before moving on t...

Share

Standard C library provides qsort() that can be used for sorting an array. As the name suggests, the function uses QuickSort algorithm to sort the given array. Follo...

Share

Sorting is one of the most basic functions applied to data. It means arranging the data in a particular fashion, which can be increasing or decreasing. There is a bui...

Share

We recommend to read following post as a prerequisite for this.
Greedy Algorithms | Set 3 (Huffman Coding)
Time complexity of the algorithm discussed in above post is...

Share

Like std::sort(), stable_sort also sorts an array. The syntax is also same.
// C++ program to demonstrate default behaviour of
// sort() in STL.
#include ...

Share

The sort_heap( ) is an STL algorithm which sorts a heap within the range specified by start and end. Sorts the elements in the heap range [start, end) into ascending ...

Share

We have discussed qsort() in C. C++ STL provides a similar function sort that sorts a vector or array (items with random access). Below is a simple program to show...

Share