0 votes 0 votes int sum(int array[ ] , int n){ int sum=0; for (int i=0:i<n;i++{ sum=sum+array[i]; } return sum; What will be the space complexity for above code?? jatin khachane 1 asked Jun 23, 2017 jatin khachane 1 385 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes O(1)..since no extra space is needed joshi_nitish answered Jun 23, 2017 joshi_nitish comment Share Follow See all 4 Comments See all 4 4 Comments reply srestha commented Jun 23, 2017 reply Follow Share depend on n , rt? then should be O(n) 0 votes 0 votes jatin khachane 1 commented Jun 23, 2017 reply Follow Share For array it dont require mem..it take only pointer to array 0 votes 0 votes srestha commented Jun 23, 2017 reply Follow Share but here n elements in array 0 votes 0 votes joshi_nitish commented Jun 24, 2017 reply Follow Share but array is already supplied in a function...if it had been defined inside function then it would be O(n).. 0 votes 0 votes Please log in or register to add a comment.