Without performing any calculations, give the worst case time complexity of the following function. Justify your answer.
void f(int k, int n)
{
int i;
for (i=0; i< n && k >0; i++)
k = k / 2;
}
Difficulty level
This exercise is mostly suitable for students
O(min(n,log2k))
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Forest of Binary Search Trees