Solution: Big O of a Nested Loop with Subtraction
Review the solution to calculate the time complexity of a nested loop with subtraction.
We'll cover the following...
Solution #
Press + to interact
int n = 10; // 'n' can be anything, this is just an exampleint sum = 0;double pie = 3.14;for (int i = n; i > 1; i -= 3){System.Console.WriteLine(pie);for (int j = n; j > 0; j--){sum += 1;}}System.Console.WriteLine(sum);
Explanation
The variable var
gets set to ...