Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

GATE | GATE-CS-2003 | Question 62

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In a permutation a1… of n distinct integers, an inversion is a pair (ai, aj) such that i < j and ai > 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?


Θ (n2)


Θ (n*log(n))


Θ (n1.5)


Θ (n)

Answer: (D)


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

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads