What is the time complexity of the below function?
void fun(int n, int arr[])
{
int i = 0, j = 0;
for (; i < n; ++i)
while (j < n && arr[i] < arr[j])
j++;
}
O(n)
O(n2)
O(n*log(n))
O(n*log(n)2)
This question is part of this quiz :
Top MCQs on Complexity Analysis of Algorithms with Answers