retagged by
531 views
1 votes
1 votes
Consider the problem of adding two n-bit binary integers, stored in two n-element arrays A and B. The sum of the two integers should be stored in binary form in an (n+1)-element array C.What is the time and space complexity of it.

I think O(n) and O(1).PLz explain
retagged by

1 Answer

2 votes
2 votes
Time complexity is O(n)
but space complexity is not O(1) as it requires n element array for A and n element array for B and (n+1) element array for C
total space complexity = O(n+n+n+1) = O(n)

Related questions

9 votes
9 votes
2 answers
2
vineet.ildm asked Nov 7, 2016
5,814 views
Why space complexity of heapsort is O(1)....and why not O(logn)..because of space required by recursion calls which is equivalent to height of the tree...where am i getti...
0 votes
0 votes
1 answer
3
Daniyal89 asked Sep 30, 2018
695 views
Ans given is option-B