It seems the complexity of the following code should be O(n^2) but it\'s O(n), how?
void fun(int n, int arr[]) { int i = 0, j = 0; for(; i < n; ++
The answer is O(n) The outer loop runs 'n' times and the inner loop only runs to 'n' a single time in all the iterations combined as the value of j is never reset to 0. Therefore the answer is O(n+n)=O(n).