You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compute Big(O) of an algorithm that involves nested loops and the loop variables decrement.
public static void main(String[] args) {
int n = 10; // O(time complexity of the called function)
int sum = 0; //O(1)
double pie = 3.14; //O(1)
//O(?)
for (int var = n; var >= 1; var = var - 3) {
System.out.println("Pie: " + pie);
//O(?)
for (int j = n; j >= 0; j = j - 1) {
sum++;
}
} //end of outer for loop
System.out.println("Sum: " + sum);//O(1)
}
The text was updated successfully, but these errors were encountered:
Compute Big(O) of an algorithm that involves nested loops and the loop variables decrement.
The text was updated successfully, but these errors were encountered: