Technically linear!
On Mon, Nov 26, 2012 at 9:47 PM, shady sinv...@gmail.com wrote:
what is the time complexity of this?
str_reverse(str){
if(isempty(str)) return str;
else if(length(str) = even) then split str into str_1 and str_2; (of
equal length) (Calculate mid =O(1), then
Yes, my bad. I din notice the recursion at all! Thot it to be a flat
mid-split followed by a reverse followed by a concat. Thanks.
On Mon, Nov 26, 2012 at 11:18 PM, atul anand atul.87fri...@gmail.comwrote:
considering '+' , here will take Cn time . Here '+' is for concatenate ,
now this
considering '+' , here will take Cn time . Here '+' is for concatenate ,
now this concatenation taking place in constant time?? , i dont think
so..internally it will be adding elements to new m/m space and for that it
need to traverse each character...so it will take cn time.
so T(n) =T(n/2) + cn