3 votes 3 votes Consider the following statements The best case complexity of insertion sort is $\Omega \left ( n^{2} \right )$ The best case complexity of insertion sort is $O\left ( n \right )$ Which one true? Algorithms time-complexity + – srestha asked Nov 11, 2017 srestha 914 views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments Anu007 commented Nov 11, 2017 reply Follow Share how can be both are true: 1st say > n2 2nd say < n https://gateoverflow.in/128680/derive-the-best-and-worst-case-complexity-of-insertion-sort https://www.khanacademy.org/computing/computer-science/algorithms/insertion-sort/a/analysis-of-insertion-sort 1 votes 1 votes srestha commented Nov 11, 2017 reply Follow Share yes tnks 0 votes 0 votes srestha commented Nov 11, 2017 reply Follow Share if it is told $\Omega \left ( n \right )$ then it will be correct? because $\Omega$ means $\geq$ right? 0 votes 0 votes Please log in or register to add a comment.
Best answer 3 votes 3 votes 2nd option is true! Explanation :- Best Case O(n) - If the input is in ascending order then we need only n comparisons for n elements and no movements Worst case O(n2) - if input is in descending or other than ascending order. Because if input is in Desc order we need to do n comparisons and at max (n-1) movements. Ashwin Kulkarni answered Nov 11, 2017 • selected Nov 11, 2017 by srestha Ashwin Kulkarni comment Share Follow See 1 comment See all 1 1 comment reply $ruthi commented Nov 12, 2017 reply Follow Share i guess both are true because Big Omega will be in the form of >=c and Big Oh is <=c 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Insertion sort Best case is O(n). which can be written as Ω(n^2) because bound will be >=c, here c is 'n'. As far as I know this is correct. If its wrong then correct me. $ruthi answered Nov 12, 2017 $ruthi comment Share Follow See all 2 Comments See all 2 2 Comments reply Ashwin Kulkarni commented Nov 12, 2017 reply Follow Share Big O is the tightest upper bound and Omega is tightest lower bound! In Insertion sort If best case in O(n) then how come its tightest lower bound is of (n^2). Hence option 1 is incorrect. 0 votes 0 votes $ruthi commented Nov 12, 2017 reply Follow Share got it. thank u :) 0 votes 0 votes Please log in or register to add a comment.