How to determine memory and time complexity of an algorithm?

Viewed 19489

I am not good at determining time and memory complexities and would appreciate it if someone could help me out.

I have an algorithm, here and I am not sure what its time and memory complexities would be.

Function sample(k)
   IF k < 2
       Return 0
   Return 1 + sample(k/2)

What is its time and memory complexity and why?

Thanks

2 Answers
Related