Given a string, find all palindromic permutations of it.
Given a list of words, efficiently group all anagrams together. X and Y are anagrams if by rearranging the letters of X, we can get Y using all the original letters of X exactly once.
Given an array consisting of positive and negative integers, segregate them in linear time and constant space. Output should print contain all negative numbers followed by all positive numbers.
Given an array, find the number of inversions of it. If (i < j) and (A[i] > A[j]) then the pair (i, j) is called an inversion of an array A. We need to count all such pairs in the array.
Given two arrays, reorder elements of first array by order of elements defined by the second array. Elements which are not present in the second array but present in first array should be appended in the end sorted. Second array can contain some extra elements which are not part of first array.
Given an array, sort its element by their frequency and index. i.e. – If two elements have the different frequencies, then the one which has more frequency should come first. – If two elements have the same frequencies, then the one which has less index should come first.
We can efficiently sort massive amounts of data using External Merge Sort Algorithm, when the data being sorted don’t fit into the main memory (which is usually RAM) and resides in the slower external memory (which is usually a hard disk).
In this article, hybrid of Quick Sort algorithm with Insertion Sort is discussed to achieve better performance.
Write iterative version of recursive Quicksort algorithm.
Given an array of integers, sort it using quicksort algorithm. Quicksort is an efficient in-place sorting algorithm, which usually performs about two to three times faster than merge sort and heapsort when implemented well.
Given an array of integers, sort it using merge sort algorithm. Merge sort is an efficient in-place sorting algorithm which produces a stable sort, which means that if two elements have the same value, they holds same relative position in the output as they did in the input.
Given an array of integers, sort it using bubble sort algorithm. Bubble sort is a stable, in-place sorting algorithm that is named for the way smaller or larger elements “bubble” to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even when compared …