Data Structures and Algorithms - Performance Analysis of Algorithms and Recurrences

Avatto > > UGC NET COMPUTER SCIENCE > > PRACTICE QUESTIONS > > Data Structures and Algorithms > > Performance Analysis of Algorithms and Recurrences

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

  • Option : C
  • Explanation :
    Minimum no of swap for selection sort is O when array is already sorted and maximum swap is Q(n).
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


102. If we use Radix Sort to sort n integers in the range (nk/12, nk], for some k > 0 which is independent of n, the time taken would be

  • Option : C
  • Explanation :
    Time complexity of radix sort is = O(nd)
    Where n = keys, d = maximum digit in keys.
    = d = log (nk)
    O(nd) = O(n * k logn)
    = k × O (nlogn)
    = O(nlogn)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


103. The number of elements that can be stored in Θ(log n) time using heap sort is

  • Option : C
  • Explanation :
    Let the number of element is “K”, they can be sorted in Θ(k log k) time.
    We try the options in decreasing order of complexity since, we need a tight band i.e. Θ

    So if K ∈ Θ(log n) time required for loop sort is.
    Θ(k log k) i.e.
    Θ(log n x log log n), But this is not in Θ(log n)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


104. Let P be a quicksort program to sort numbers in ascending order. Let t1 and t2 be the time taken by the program for the inputs [1 2 3 4] and [5 4 3 2 1], respectively. Which of the following holds?

  • Option : A
  • Explanation :
    It input is in either ascending order or in descending order both are worst case of quick sort Algorithms.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


105. Quicksort is run on two inputs shown below to sort in ascending order
(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,

  • Option : C
  • Explanation :
    If Input is either in ascending order or in descending order both are worst case of quick sort algorithm
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *