Skip to content

Tag Archives: Merge Sort

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
Ever wondered how sort() function we use in C++/Java or sorted() in Python work internally? Here is a list of all the inbuilt sorting algorithms… Read More
Given K sorted linked lists of size N each, merge them and print the sorted output. Examples:  Input: k = 3, n = 4 list1… Read More
Given a set of elements, find which permutation of these elements would result in worst case of Merge Sort.Asymptotically, merge sort always takes O(n Log… Read More
Given two sorted singly linked lists having n and m elements each, merge them using constant space. First n smallest elements in both the lists… Read More
Given a linked list that is sorted based on absolute values. Sort the list based on actual values. Examples:   Input : 1 -> -10 output:… Read More
External sorting is a term for a class of sorting algorithms that can handle massive amounts of data. External sorting is required when the data… Read More
We are given two sorted arrays. We need to merge these two arrays such that the initial numbers (after complete sorting) are in the first… Read More
Given two linked lists sorted in increasing order. Merge them such a way that the result list is in decreasing order (reverse order). Examples:  Input:… Read More
Given a Linked List. The Linked List is in alternating ascending and descending orders. Sort the list efficiently.  Example:  Input List: 10 -> 40 ->… Read More
Consider a big array where elements are from a small set and in any range, i.e. there are many repetitions. How to efficiently sort the… Read More
Given a big list of dates in ’20s, how to efficiently sort the list.  Example:  Input: Date arr[] = {{20, 1, 2014}, {25, 3, 2010},… Read More
Why is Quick Sort preferred for arrays? Below are recursive and iterative implementations of Quick Sort and Merge Sort for arrays. Recursive Quick Sort for… Read More
Given a doubly linked list, write a function to sort the doubly linked list in increasing order using merge sort.For example the following doubly linked… Read More
Following is a typical recursive implementation of Merge Sort that uses last element as pivot. Java // Recursive Java Program for merge sort   import… Read More

Start Your Coding Journey Now!