Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago