Thursday, February 26, 2026
HomeData Modelling & AIAlgorithms | Sorting | Question 12

Algorithms | Sorting | Question 12

What is the worst case time complexity of insertion sort where position of the data to be inserted is calculated using binary search?

(A)

N

(B)

N*log(N)

(C)

N2

(D)

N*log(N)2

Answer: (C)
Explanation:

Applying binary search to calculate the position of the data to be inserted doesn’t reduce the time complexity of insertion sort.

This is because the insertion of data at an appropriate position involves two steps:

  1. Calculate the position.
  2. Shift the data from the position calculated in step #1 one step right to create a gap where the data will be inserted.
  3. Using binary search reduces the time complexity in step #1 from O(N) to O(log(N)). But, the time complexity in step #2 still remains O(N).

 So, overall complexity remains O(N2).

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS