• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Sorting Algorithms with Answers

Question 41

Quicksort is run on two inputs shown below to sort in ascending order taking the first element as pivot,

(i) 1, 2, 3,......., n
(ii) n, n-1, n-2,......, 2, 1 

Let C1 and C2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,

  • C1 < C2 
     

  • C1 > C2

  • C1 = C2

  • We cannot say anything for arbitrary n

Question 42

A two dimensional array A[1...n][1...n] of integers is partially sorted if
i, j ∈ [1...n−1], A[i][j] < A[i][j+1] and A[i][j] < A[i+1][j]
Fill in the blanks: a) The smallest item in the array is at A[i][j] where i=..................and j=...................... b) The smallest item is deleted. Complete the following O(n) procedure to insert item x (which is guaranteed to be smaller than any item in the last row or column) still keeping A partially sorted.
procedure insert (x: integer);
var i,j: integer;
begin
    i:=1; j:=1, A[i][j]:=x;
    while (x > ...... or x > ......) do
        if A[i+1][j] < A[i][j] ......... then begin
            A[i][j]:=A[i+1][j]; i:=i+1;
        end
        else begin
            ............
        end
    A[i][j]:= .............
end
.

    Question 43

    A sorting technique is called stable if
    • If it takes O(n log n) time
    • It uses divide and conquer technique
    • Relative order of occurrence of non-distinct elements is maintained
    • It takes O(n) space

    Question 44

    You are given a sequence of n elements to sort. The input sequence consists of n/k subsequences,each containing k elements. The elements in a given subsequence are all smaller than the elements in the succeeding subsequence and larger than the elements in the preceding subsequence. Thus, all that is needed to sort the whole sequence of length n is to sort the k elements in each of the n/k subsequences. The lower bound on the number of comparisons needed to solve this variant of the sorting problem is
    • Ω (n)
    • Ω (n/k)
    • Ω (nlogk )
    • Ω (n/klogn/k)

    Question 45

    Which of the following is true for computation time in insertion, deletion and finding maximum and minimum element in a sorted array ?
    • Insertion – 0(1), Deletion – 0(1), Maximum – 0(1), Minimum – 0(l)
    • Insertion – 0(1), Deletion – 0(1), Maximum – 0(n), Minimum – 0(n)
    • Insertion – 0(n), Deletion – 0(n), Maximum – 0(1), Minimum – 0(1)
    • Insertion – 0(n), Deletion – 0(n), Maximum – 0(n), Minimum – 0(n)

    Question 46

    Consider the following sorting algorithms. 
    I. Quicksort 
    II. Heapsort 
    III. Mergesort 
    Which of them perform in least time in the worst case?

    • I and II only

    • II and III only

    • III only

    • I, II and III

    Question 47

    Which one of the following in place sorting algorithms needs the minimum number of swaps?

    • Quick sort

    • Insertion sort

    • Selection sort

    • Heap sort

    Question 48

    Selection sort algorithm design technique is an example of
    • Greedy method
    • Divide-and-conquer
    • Dynamic Programming
    • Backtracking

    Question 49

    The average case and worst case complexities for Merge sort algorithm are
    • O ( n2 ), O ( n2 )
    • O ( n2 ), O ( n log2n )
    • O ( n log2n ), O ( n2)
    • O ( n log2n ), O ( n log2n )

    Question 50

    You have to sort a list L, consisting of a sorted list followed by a few ‘random’ elements. Which of the following sorting method would be most suitable for such a task?
    • Bubble sort
    • Selection sort
    • Quick sort
    • Insertion sort

    There are 61 questions to complete.

    Last Updated :
    Take a part in the ongoing discussion