Vidyalelo
Data Structure · all questions

Sorting Algorithms
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

509

Questions

6/26

Page

Pick an option on a question to see the right answer and solution.

What is the worst case time complexity of the Quick sort?

Select an option to see the answer and solution.

Which of the following is a comparison based sort?

Select an option to see the answer and solution.

What is the worst case time complexity of library sort?

Select an option to see the answer and solution.

Choose the incorrect statement about merge sort from the following?

Select an option to see the answer and solution.

What will be the output of the given Java code?
import java.util.Arrays; 
public class SortExample 
{ 
	public static void main(String[] args) 
	{ 
		// Our arr contains 8 elements 
		int[] arr = {10,7,9,5,8,4}; 
		Arrays.sort(arr); 
		System.out.printf(Arrays.toString(arr)); 
	} 
}

Select an option to see the answer and solution.

What is the worst case time complexity of cycle sort?

Select an option to see the answer and solution.

The gap value after 3 iterations in an array with 6 elements will be . . . . . . . .

Select an option to see the answer and solution.

Which one of the following is a variation of Heap sort?

Select an option to see the answer and solution.

Heap sort is an implementation of . . . . . . . . using a descending priority queue.

Select an option to see the answer and solution.

Shell sort algorithm is an example of?

Select an option to see the answer and solution.

Which of the following version of tree sort will have the highest worst case time complexity?

Select an option to see the answer and solution.

In average case Heap sort is as efficient as the Quick sort.

Select an option to see the answer and solution.

Quick sort uses which of the following method to implement sorting?

Select an option to see the answer and solution.

LSD radix sort is in-place sorting algorithm.

Select an option to see the answer and solution.

What is the average case time complexity of cube sort?

Select an option to see the answer and solution.

The gap between two elements being compared shrinks by a factor of . . . . . . . . after every iteration.

Select an option to see the answer and solution.

The following function represents which sorting?
void Sorting(int a[], int n) 
{ 
	bool swap = true; 
	int first = 0; 
	int last = n - 1; 
 
	while (swap) 
        { 
 
		swap = false; 
 
		for (int i = first; i < last;i++)
                { 
			if (a[i] > a[i + 1]) 
                        { 
				swap(a[i], a[i + 1]); 
				swap = true; 
			} 
		} 
 
		if (!swap) 
			break; 
 
		swap = false; 
 
		--last; 
 
 
		for (int i = last - 1; i >= first; i--)
                { 
			if (a[i] > a[i + 1]) 
                        { 
				swap(a[i], a[i + 1]); 
				swap = true; 
			} 
		} 
 
		++first; 
	} 
}

Select an option to see the answer and solution.

What is the best case time complexity of odd-even sort?

Select an option to see the answer and solution.

The insert() procedure, given below, builds the BST on the input elements, which is the first step of the binary tree sort. Choose the correct to fill the condition.
void insert(Tree* node, int newElement)
{
	if(node== NULL)
	{
		node = createNewNode();
		node-> value = newElement;
		node -> left = NULL;
		node -> right = NULL;
		return;
	}
	else if(__________________)
	{
		insert(node->left, newElement);
	}
	else
	{
		insert(node->right, newElement);
	}
}

Select an option to see the answer and solution.

What is the worst case time complexity of binary insertion sort?

Select an option to see the answer and solution.