when the for loop executes and ends for 1st case m = 2n
now this value of m goes to the function g() which runs till ( 2n/2 <=1)
--- means stack space : O(n)
now we goto function f() again which executes for (n/2k<=1) and as n decrements by 1/2 every time.
---its stack space : O(logn)
now as value of function f(n)--->f(n/2) than function g() will have stack space as O(n-1) but for finding stack space we consider only the maximum stack space...
now cosidering other statements time complexity to be constant. O(1)
overall space complexity : O(n) +O(logn)+O(1) = O(n) solution.