If this is homework (and it sounds a bit like it), then you should try yourself first.
Basically, to get complete, you look at the structure of the function, that is, at the loops, nesting loops, etc., and determine how long they work, what inputs depend on them, etc.
In this case, you have only one input, n. The local variable h starts with the same value as n, so it is essentially the same and complex, however you need to keep track of how it is used.
Here you have essentially two nested loops, one of which works with n, the other around it, which causes h to be halved each time it starts. So this function is in O (n Β· log 2 n).
source share