Bubble sort, selection sort and insertion sort all have a time complexity of:
An plus n
Bn over n
Cn minus n
Dn squared
Answer & Solution
Correct answer: D. n squared
1. Each of the three programs contains a nested loop.
2. A nested loop gives a squared cost.
3. So all three run in n squared time.
_Source: syllabus Computer Science Class XII, Chapter 5, Sorting._
Keep practising Sorting Algorithms
Browse all Sorting Algorithms questions for Engineering — Tanzania, or explore more Computer Science topics.