# Tag Archives: Merge Sort

## Find array with k number of merge sort callsNovember 9, 2017

Given two numbers n and k, find an array containing values in [1, n] and requires exactly k calls of recursive merge sort function. Examples:… Read More »

## Counting cross lines in an arrayNovember 5, 2017

Given an unsorted array of distinct elements. Task is to count number of cross lines formed in an array elements after sorting the array elements.… Read More »

## How to make Mergesort to perform O(n) comparisons in best case?September 17, 2017

As we know, Mergesort is a divide and conquer algorithm that splits the array to halves recursively until it reaches an array of the size… Read More »

## Subarray InversionsAugust 10, 2017

We have an array A of n integers that we’re planning on sorting. Specifically, we want to know how close the array is to sorted.… 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 »

## Union and Intersection of two linked lists | Set-2 (Using Merge Sort)June 14, 2017

Given two Linked Lists, create union and intersection lists that contain union and intersection of the elements present in the given lists. Order of elements… Read More »

## Merge two sorted arraysMay 31, 2017

Given two sorted arrays, the task is to merge them in a sorted manner. Examples: Input : arr1[] = { 1, 3, 4, 5} arr2[]… Read More »

## TimSortMay 19, 2017

TimSort is a sorting algorithm based on Insertion Sort and Merge Sort. A stable sorting algorithm works in O(n Log n) time Used in Java’s… Read More »

## Minimum swaps to reach permuted array with at most 2 positions left swaps allowedMarch 26, 2017

Given a permuted array of length N of first N natural numbers, we need to tell the minimum number of swaps required in the sorted… Read More »

## Sorting possible using size 3 subarray rotationMarch 8, 2017

Given an array of integer values which need to be sorted by only one operation – subarray rotation where subarray size should be 3. For… Read More »

## Sort an array when two halves are sortedJanuary 18, 2017

Given an integer array of which both first half and second half are sorted. Task is to merge two sorted halves of array into single… Read More »

## Concurrent Merge Sort in Shared MemoryJuly 25, 2016

Given a number ‘n’ and a n numbers, sort the numbers using Concurrent Merge Sort. (Hint: Try to use shmget, shmat system calls). Part1: The… Read More »

## Merge operations using STL in C++ (merge, includes, set_union, set_intersection, set_difference, ..)July 19, 2016

Some of the merge operation classes are provided in C++ STL under the header file “algorithm”, which facilitates several merge operations in a easy manner.… Read More »

## Find Surpasser Count of each element in arrayJuly 9, 2016

A surpasser of an element of an array is a greater element to its right, therefore x[j] is a surpasser of x[i] if i <… 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 »