Question: Calculate and write the Time Complexity of each example below in Big O notation static void bigO_Example1( int n) { int x = 365; for

Calculate and write the Time Complexity of each example below in Big O notation

static void bigO_Example1(int n) { int x = 365; for (int i = n - 2; i > 1; i--) { x = 365 + 1; } Console.WriteLine(x.ToString()); for (int i = 0; i < n; i++) { Console.WriteLine(x == i); } for (int i = 0; i < 6; i++) { x = i; } } static void bigO_Example2(int n) { int x = 10; for (int i = n; i >= 1; i = i - 4) { x++; } Console.WriteLine(x.ToString()); } static void bigO_Example3(int n) { int x = 10; for (int i = 1; i < n; i = i + 5) { --x; } Console.WriteLine(x.ToString()); }

static void bigO_Example4(int n) { int x = 10; for (int i = n - 1; i >= 1; i / 2) { x++; } Console.WriteLine(x.ToString()); } static void bigO_Example5(int n) { int x = 10; for (int i = 1; i < n; i *= 2) { ++x; } Console.WriteLine(x.ToString()); } static void bigO_Example6(int n) { int x = 10; for (int i = 0; i < n; i++) { x = i; for (int j = 0; j < n; j++) { int y = 0; int z = 10 - 10; Console.WriteLine((y == z).ToString()); } } x = x + 10; Console.WriteLine(x.ToString()); } static void bigO_Example7(int n) { int x = 10; for (int i = 0; i < n; i++) { for (int j = n - 1; j >= 1; j /= 2) { x++; } for (int k = 0; k < n; k++) { --x; } } x = x + 10; Console.WriteLine(x.ToString()); } static void bigO_Example8(int n) { int x = 10; for (int i = 0; i < n; i++) { for (int j = 0; j >= 1; j++) { x++; } } if (x > 10) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { --x; } } } else { for (int i = 0; i < n; i++) { x++; } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!