Dont know about the space complexity


#1

dont know about the space complexity


#2

variable a and b are constants. Both loops are doing some processing and storing the values to a or b. which is constant… so the bigOh is constant storage. so we denote constant storage as bogOh(1).

In the same way, if both loops are considering new variable to store values at each loop pass then it would be directly proportional to the number of elements in the array. Means If loop will run to 10 times then 10 storage would be needed. If loop will run to 1000 times then 1000 storage would be needed. It means bigOh in that case could be bigOh(N)