# Tag Archives: Merge Sort

Given k sorted arrays of size n each, merge them and print the sorted output. Example:  Input: k = 3, n = 4 arr[][] = { {1,… Read More
Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the… Read More
Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the… Read More
Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the… Read More
Given two Binary Search Trees(BST), print the elements of both BSTs in sorted form. The expected time complexity is O(m+n) where m is the number… Read More
The problem of sorting can be viewed as following.  Input: A sequence of n numbers <a1, a2, . . . , an>. Output: A permutation (reordering)… Read More
Stability is mainly important when we have key value pairs with duplicate keys possible (like people names as keys and their details as values). And… Read More
Merge sort is often preferred for sorting a linked list. The slow random-access performance of a linked list makes some other algorithms (such as… Read More
Write a SortedMerge() function that takes two lists, each of which is sorted in increasing order, and merges the two together into one list which… Read More
Given two sorted arrays, find their union and intersection. Example: Input : arr1[] = {1, 3, 4, 5, 7} arr2[] = {2, 3, 5, 6}… Read More
Write a removeDuplicates() function that takes a list and deletes any duplicate nodes from the list. The list is not sorted. For example if the linked… Read More
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If the array is already sorted, then… Read More