C Program for Iterative Merge Sort

Following is a typical recursive implementation of Merge Sort that uses last element as pivot. filter_none edit close play_arrow link brightness_4 code /* Recursive C… Read More »

Python Program for Iterative Merge Sort

Following is a typical recursive implementation of Merge Sort that uses last element as pivot. Python filter_none edit close play_arrow link brightness_4 code # Recursive… Read More »

MAQ Software Interview Experience | Set 5

1st round – 30 min,30 MCQs (IQ test) 2nd round – Coding test(30 min) Q1-> Insertion sort Q2-> Reverse a number using recursion Q3-> Didn’t… Read More »

Merge k sorted arrays | Set 1

Given k sorted arrays of size n each, merge them and print the sorted output. Example: Input: k = 3, n = 4 arr[][] =… Read More »

Java Program for Merge Sort

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 »

Python Program for Merge Sort

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 »

C Program for Merge Sort

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 two BSTs with limited extra space

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 »

Lower bound for comparison based sorting algorithms

The problem of sorting can be viewed as following. Input: A sequence of n numbers <a1, a2, . . . , an>. Output: A permutation… Read More »

Stability in sorting algorithms

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 for Linked Lists

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 quicksort)… Read More »

Merge two sorted linked lists

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 »

Union and Intersection of two sorted arrays

Given two sorted arrays, find their union and intersection. Example: Input : arr1[] = {1, 3, 4, 5, 7} arr2[] = {2, 3, 5, 6}… Read More »

Remove duplicates from an unsorted linked list

Write a removeDuplicates() function which takes a list and deletes any duplicate nodes from the list. The list is not sorted. For example if the… Read More »

Count Inversions in an array | Set 1 (Using Merge Sort)

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count… Read More »