Skip to content
Related Articles
Open in App
Not now

Related Articles

GATE | GATE-CS-2003 | Question 62

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

In a permutation a1… of n distinct integers, an inversion is a pair (ai, aj) such that i aj. What would be the worst case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of 1…..n with at most n inversions?
(A) Θ (n2)
(B) Θ (n log n)
(C) Θ (n1.5)
(D) Θ (n)

Answer: (D)

Explanation: Insertion sort runs in Θ(n + f(n)) time, where f(n) denotes the number of inversion initially present in the array being sorted.


Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!