Hi there. Just a quick question about Big O.
If you take this simple code:
public class delete {
public static void main(String args[]) {
test(10000);
}
public static int test(int numberIn) {
int x = 0;
if (x != 0) { return 1; }
int y[] = new int[numberIn];
int x[] = new int[numberIn];
return 0;
}
}
I understand that the statements "int x = 0" is O(1) + k because it is so simple. I realise that "if (x != 0) { return 1; }" is also O(1) +k as it is so simple.
I am a bit unsure of what this is: int y[] = new int[numberIn]; because the input gets passed to the statement. If the input was just 5 for instance then it would be no problem. But if the input was a billion say, surely it would take longer for the new int statement to perform its function?
Should I just assume that the int y[] = new int[numberIn]; (and x[] = new int[numberIn]) are both just simple O(1) statements or is each one a O(N) statement equalling O(n2)?
Thanks
Start Free Trial