2 votes 2 votes for i <--- 1 to n for j <---- 1 to n/2 X = X + 1 (i and j both are incrementing by 1) Outer runs for n times and inner for n/2 So will it be n(n/2) => O(n^2) times... Algorithms time-complexity algorithms asymptotic-notation + – aka 53 asked Nov 22, 2017 edited Nov 22, 2017 by aka 53 aka 53 958 views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments aka 53 commented Nov 22, 2017 reply Follow Share Ohh my apologies ..i edited it now 1 votes 1 votes kirti_k commented Nov 22, 2017 reply Follow Share yes now it is $n^{2}$ 0 votes 0 votes abhishek tiwary commented Nov 26, 2017 reply Follow Share outer loop is running n times and inner is n/2 times so its complexity will be n*n/2=O(n2) 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Here +1 in each loop check the false condition. Hira Thakur answered Nov 28, 2017 Hira Thakur comment Share Follow See all 0 reply Please log in or register to add a comment.