Question: What is the best-case time complexity of Insertion Sort?
Options:
O(n log n)
O(n^2)
O(n)
O(log n)
Correct Answer: O(n)
Solution:
The best-case time complexity of Insertion Sort is O(n) when the array is already sorted.
What is the best-case time complexity of Insertion Sort?
Practice Questions
Q1
What is the best-case time complexity of Insertion Sort?
O(n log n)
O(n^2)
O(n)
O(log n)
Questions & Step-by-Step Solutions
What is the best-case time complexity of Insertion Sort?
Step 1: Understand what Insertion Sort is. It is a sorting algorithm that builds a sorted array one element at a time.
Step 2: Know that the best-case scenario occurs when the array is already sorted.
Step 3: In this case, Insertion Sort only needs to check each element once to confirm it is in the correct position.
Step 4: Since there are 'n' elements in the array, the algorithm will make 'n' comparisons.
Step 5: Therefore, the time taken in the best-case scenario is proportional to 'n', which is expressed as O(n).
Best-case Time Complexity – The best-case time complexity refers to the scenario where the algorithm performs the least number of operations, which for Insertion Sort occurs when the input array is already sorted.
Insertion Sort – Insertion Sort is a simple sorting algorithm that builds the final sorted array one item at a time, with a best-case scenario of O(n) when the input is already sorted.
Soulshift Feedback×
On a scale of 0–10, how likely are you to recommend
The Soulshift Academy?