Would the following code be O(n^2) or O(n)?
int i=0, j=0;
while (i < n) {
while (j < n) {
j++;
}
i++;
}
Since the inner while loop only runs once from 0 to n I would imagine it's equivalent to having two separate while loops thus the total run-time would be O(2n).