Skip to content

Tag Archives: Merge Sort

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: -10… 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  C++ // Recursive C++ program for merge sort #include<bits/stdc++.h> using namespace std;   // Function to… Read More
Following is a typical recursive implementation of Merge Sort that uses last element as pivot. /* Recursive C program for merge sort */ #include <stdio.h>… 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
Following is a typical recursive implementation of Merge Sort that uses last element as pivot. Python # Recursive Python Program for merge sort    def… Read More
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