1 1 vote I always thought the complexity of: 1 + 2 + 3 + ... + n is O(n), and summing two n by n matrices would be O(n^2). But today I read from a textbook, "by the formula for the sum of the first n integers, this is n(n+1)/2" and then thus: (1/2)n^2 + (1/2)n, and thus O(n^2). What am I missing here? Algorithms algorithms time-complexity + – learner_geek 605 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
0 0 votes actually if someone ask TC of value produced by sum of n natural numbers then TC=O(n2) if asked TC of the computation to produce this sum then TC=O(n) it's just like TC of multiplication for factorial n (n!) is O(n) while TC of value produced is O(nn) Rupendra Choudhary answered Jun 5, 2017 Rupendra Choudhary comment Share Follow 0 reply Please log in or register to add a comment.