Merge Sort MCQ Quiz in తెలుగు - Objective Question with Answer for Merge Sort - ముఫ్త్ [PDF] డౌన్లోడ్ కరెన్
Last updated on Mar 16, 2025
Latest Merge Sort MCQ Objective Questions
Top Merge Sort MCQ Objective Questions
Merge Sort Question 1:
Consider 5 array of size 25, 31, 37, 49, 57 respectively. All arrays are sorted. All the arrays into a single array by using the Merge Sort algorithm and the single array is again a sorted array. What is the maximum number of comparisons that will be needed in the worst case?
Answer (Detailed Solution Below) 450
Merge Sort Question 1 Detailed Solution
Using Merge Sort
Sequence: 25, 31, 37, 49, 57
Ascending order: 25, 31, 37, 49, 57
Merge(25, 31) → new size (56)
Number of comparisons = 25 + 31 – 1 = 55
Sequence: 37, 49, 56, 57
Merge(37, 49) → new size (86)
Number of comparisons = 37 + 49 – 1 = 85
Sequence: 56, 57, 86
Merge(56, 57) → new size (113)
Number of comparisons = 56 + 57 – 1 = 112
Sequence: 86, 113
Merge(86, 113) → new size (199)
Number of comparisons = 86 + 113 – 1 = 198
Therefore, total number of comparisons, 55+ 85 + 112 + 198 = 450
Merge Sort Question 2:
Which of the following has the least worst time complexity?
Answer (Detailed Solution Below)
Merge Sort Question 2 Detailed Solution
Worst time complexity is as follows:
Bubble Sort - O(N2)
Merge Sort - O(N log N)
Insertion Sort - O(N2)
Selection Sort - O(N2)Merge Sort Question 3:
Which of the following sort algorithms has execution time that is least dependent on initial ordering of the input?
Answer (Detailed Solution Below)
Merge Sort Question 3 Detailed Solution
Option_1: Insertion Sort
In Insertion sort, if the array is already sorted, then it takes O(n) time and if it is sorted is decreasing order, then it takes O(n2) time to sort the array.
Option_2: Quick Sort
In Quick sort, if the array is already sorted whether in decreasing or in non-decreasing order, then it takes O(n2) time.
Option_3 – Merge Sort
Merge sort gives time complexity of O(nlogn) in every case, be it best, average or worst. In merge sort, performance is affected least by the order of input sequence.
Option_4: Selection Sort
For selection sort, the best- case and worst-case performance of Selection is O(n2) only. But if the array is already sorted then less swaps are required.Merge Sort Question 4:
What is mean by stable sorting algorithm?
Answer (Detailed Solution Below)
Merge Sort Question 4 Detailed Solution
Concept
The stability of a sorting algorithm is concerned with how the algorithm treats equal (or repeated) elements.
A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.
Some sorting algorithms are stable by nature like Insertion sort, Merge Sort, Bubble Sort, etc. And some sorting algorithms are not, like Heap Sort, Quick Sort, etc.
Merge Sort Question 5:
Time complexity of Merge Sort Algorithm and Binary Search Algorithm are respectively:
Answer (Detailed Solution Below)
Merge Sort Question 5 Detailed Solution
Merge sort
It is based on the divide and conquers approach.
Recurrence relation for merge sort will become:
T(n) = 2T (n/2) + Θ (n)
Using Master’s theorem
T (n) = n × log2n
Therefore, the time complexity of Merge Sort is θ(nlogn).
Binary Search
Search a sorted array by repeatedly dividing the search interval in half.
Recurrence for binary search is T(n) = T(n/2) + θ(1)
Using Master’s theorem
T (n) = log2n
Consider only half of the input list and throw out the other half. Hence time complexity is O(log n).
Merge Sort Question 6:
It is required to sort a large number of records of Student details of a college based on the student IDs. Assuming the records are already sorted on the basis of Student names and it is required to maintain name as the secondary sort order (similar to order by id, name in SQL), which of the following sorting algorithms is/are the most appropriate for this?
Answer (Detailed Solution Below)
Merge Sort Question 6 Detailed Solution
Question is implying a stable sort.
Stable sorting-:
A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.
Among the ones in option
only Merge Sort is stable. So, the correct answer is option 1 .
Merge Sort Question 7:
Which of the following sorting algorithms users recursion ?
Answer (Detailed Solution Below)
Merge Sort Question 7 Detailed Solution
Heapsort:
Heap data structure is an array object that can be viewed as a nearly complete binary tree. A heap can be a max or a min-heap. In a max heap, the maximum element will be the root of the tree, and in min heap minimum element will be the root of the tree. To make the right element as the root is heap sorting. It does not use recursion. It is based on the concept of a priority queue.
Bubble sort:
It works by repeatedly moving the largest element to the highest index position of the array. It needs swapping of the elements. It compares the adjacent elements and swaps their positions if they are not in order. Order can be ascending or descending.
Insertion sort:
In this, array elements are compared to sequentially and arranged in order. It places the unsuitable element into its right position. It repeatedly inserts an element in the sorted subarray to its left.
Merge sort:
It is a divide and conquers based algorithm. It uses recursion to sort the elements of the array. In this, the array is divided into two parts until we get the sorted subarray, then combine and sort them again and the final result will be the sorted array of elements.
Therefore merge sort algorithms users recursion.
Merge Sort Question 8:
Assume an array A having eight elements, let the total number of inversions in the array A is “x” and number of inversions for element ‘20’ and ‘65’ are “y” and “z” respectively. Find the value of expression x + yz?
Array A:
70 |
20 |
50 |
15 |
65 |
88 |
3 |
2 |
Answer (Detailed Solution Below) 25
Merge Sort Question 8 Detailed Solution
Inversion: if ( a < b) and ( A[a] > A[b] ) then there is an inversion between A[a] and A[b].
No. of inversions = Left side inversions + Right side inversions + combining inversions
Method 1: Brute force method
If there are n elements in the array then we need to do n - times linear search. So, Time complexity will be O(n2)
Which is not efficient.
Method 2: Using Divide and Conquer
- Divide the given problem into some sub-problems
- Conquer the subproblems by calling recursively until we will get subproblem solutions
- Combine the subproblem solutions, so that we will get final problem solution
Total no. of inversions we get is 19, so value of x = 19
Elements wise no. of inversions are –
For element 70 = 6 inversions
For element 20 = 3 inversions [ y = 3]
For element 50 = 3 inversions
For element 15 = 2 inversions
For element 65 = 2 inversions [ z = 2]
For element 85 = 2 inversions
For element 3 = 1 inversions
For element 2 = 0 inversions
Hence, value of x + yz = 19 + 3 × 2 = 19 + 6 = 25
Merge Sort Question 9:
Which of the following sorting algorithms users recursion ?
Answer (Detailed Solution Below)
Merge Sort Question 9 Detailed Solution
Heapsort:
Heap data structure is an array object that can be viewed as a nearly complete binary tree. A heap can be a max or a min-heap. In a max heap, the maximum element will be the root of the tree, and in min heap minimum element will be the root of the tree. To make the right element as the root is heap sorting. It does not use recursion. It is based on the concept of a priority queue.
Bubble sort:
It works by repeatedly moving the largest element to the highest index position of the array. It needs swapping of the elements. It compares the adjacent elements and swaps their positions if they are not in order. Order can be ascending or descending.
Insertion sort:
In this, array elements are compared to sequentially and arranged in order. It places the unsuitable element into its right position. It repeatedly inserts an element in the sorted subarray to its left.
Merge sort:
It is a divide and conquers based algorithm. It uses recursion to sort the elements of the array. In this, the array is divided into two parts until we get the sorted subarray, then combine and sort them again and the final result will be the sorted array of elements.
Therefore merge sort algorithms users recursion.
Merge Sort Question 10:
Given two sorted list of size ‘m’ and ‘n’ respectively. The number of comparisons needed in the worst case by the merge sort algorithm will be:
Answer (Detailed Solution Below)
Merge Sort Question 10 Detailed Solution
Concept:
Merge sort algorithm uses Divide and Conquer. Hence, we divide both our lists into m and n single-element lists respectively.
Now, we know that first m lists are sorted and after these m lists, the n lists are also sorted.
Let’s call these single element lists as m1, m2 and so on, and n1, n2 and so on.
To merge these lists into one single-sorted list, we compare
- m1 with n1.
- Either m2 with n1 or m1 with n2. Here, for sorting 3 elements, 2 comparisons are needed.
- Observe that, each element in subset of m needs to be compared with each element in subset of n. We don’t need to compare m1 with other m lists because they are sorted and same goes for n lists.
- We repeat the process until we have got a sorted list with m + n elements. This happens when we have made m + n – 1 comparisons.