1 1 vote time complexity of the program is? Programming in C + – chandra sai 650 views answer comment Share Follow Print See all 3 Comments 3 3 Comments reply chandra sai commented Jan 3, 2018 reply Follow flag ans O(n^2) 0 0 replyShare Ashwin Kulkarni commented Jan 3, 2018 reply Follow flag Is it O(n2) ? 0 0 replyShare Ashwin Kulkarni commented Jan 3, 2018 reply Follow flag Inner loop runs for (n/2 + logn) times hence bigger is n we have to take that only. Outer loop runs as, bound =1 , inner = 1*n/2 bound = 2, inner = 2*n/2 bound = 4, inner = 4*n/2 .. .. bound = 2k , inner = 2k*n/2 (n = 2^k) hence k = logn now by adding up it will give, 1*n/2 + 2*n/2 + 4*n/2 .... 2^k *n/2 n/2 [ 1+2+4 ... 2^k] n/2 * 2n O(n2) 1 1 replyShare Please log in or register to add a comment.