In a permutation a1…..an 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.
Source: http://cs.xidian.edu.cn/jpkc/Algorithm/down/Solution%20to%202-4%20Inversions.pdf
Quiz of this Question
Recommended Posts:
- GATE | GATE CS 1999 | Question 36
- GATE | GATE CS Mock 2018 | Question 39
- GATE | GATE CS 2013 | Question 1
- GATE | GATE CS 2013 | Question 3
- GATE | GATE CS 2013 | Question 4
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 6
- GATE | GATE CS 2013 | Question 7
- GATE | GATE CS 2013 | Question 8
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 11
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 17
- GATE | GATE CS 2013 | Question 18
- GATE | GATE CS 2013 | Question 19
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 22
- GATE | GATE CS 2013 | Question 23

