- #1
DorumonSg
- 64
- 0
I understand how to compare 2 functions and tell which bound they are in... but what I cannot comprehend is, given a single function... how do you write which bound it is in?
Given a simple for loop like :
for(int i = 0; i<n; i++) {
for(int i = 0; i<j; i++) {
System.out.println("Haha.");
}
}
You know that its n^2 but is it O(n^2), BigOmega(n^2) or BigTheta(n^2)?
It seems that sometimes O(n^2) is used and sometimes BigTheta(n^2) is used?
1 more question, a nested loop is usually n^of the number of nested loop. But when is it not?
Given a simple for loop like :
for(int i = 0; i<n; i++) {
for(int i = 0; i<j; i++) {
System.out.println("Haha.");
}
}
You know that its n^2 but is it O(n^2), BigOmega(n^2) or BigTheta(n^2)?
It seems that sometimes O(n^2) is used and sometimes BigTheta(n^2) is used?
1 more question, a nested loop is usually n^of the number of nested loop. But when is it not?