In-place Merge Sort Multiple choice Questions and Answers (MCQs)

 

 Help authour, Buy PDF Ebook   >>>Click Here<<<

In-place Merge Sort Multiple choice Questions and Answers (MCQs)

Question 1
Merge sort uses which of the following algorithm to implement sorting?
A
backtracking
B
greedy algorithm
C
divide and conquer
D
dynamic programming
Commerce Questions answers
Question 1 Explanation: 
Merge sort uses the technique of divide and conquer in order to sort a given array. It divides the array into two halves and apply merge sort algorithm to each half individually after which the sorted versions of these halves are merged together.

Question 2
What is the average case time complexity of standard merge sort?
A
O(n log n)
B
O(n2)
C
O(n2 log n)
D
O(n log n2)
Microbiology Questions answers
Question 2 Explanation: 
The recurrence relation for merge sort is given by T(n) = 2T(n/2) + n. This can be solved using master's theorem and is found equal to O(n log n).

Question 3
What is the auxiliary space complexity of standard merge sort?
A
O(1)
B
O(log n)
C
O(n)
D
O(n log n)
Current affairs Questions answers
Question 3 Explanation: 
The merging of two sorted arrays requires an additional space of n due to which the auxiliary space requirement of merge sort is O(n). Thus merge sort is not an in place sorting algorithm.

Question 4
What is the space complexity of in place merge sort?
A
O(1)
B
O(n)
C
O(log n)
D
O(n log n)
Education Questions answers
Question 4 Explanation: 
Space complexity of in place version of merge sort is O(log n) which is used for storing call stack formed due to recursion. Note that the algorithms with space complexity as O(log n) also qualifies as in place algorithms as the value of log n is close to 1.

Question 5
What is the average time complexity of in place merge sort when we use the following function for merging?

void in....place....merge(int arr[],  int l,  int middle,  int r) { 	int start2 = middle + 1; 	if (arr[middle] <= arr[start2]) { 		return; 	} 	while (l <= middle && start2 <= r) { 		if (arr[l] <= arr[start2]) { 			l++; 		} 		else { 			int val = arr[start2]; 			int index = start2; 			while (index != l) { 				arr[index] = arr[index - 1]; 				index--; 			} 			arr[l] = val; 		 l++; 			middle++; 			start2++; 		} 	} }
A
O(n log n)
B
O(n2)
C
O(n2 log n)
D
O(n log n2)
UPSC Questions answers
Question 5 Explanation: 
The merge function in the in place merge sort takes O(n2) time so the recurrence relation becomes T(n)=2T(n/2)+n2. This can be solved using master's theorem and is found equal to O(n2).

There are 5 questions to complete.

 

 Download all FREE PDF Ebook >>>CLICK HERE<<<