Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I'm in need of help with this assignment, it's C++ but deals with Big O. This is to be done with pencil and paper,

Hi, I'm in need of help with this assignment, it's C++ but deals with Big O. This is to be done with pencil and paper, no code at all. Here are the problems:

  1. Does Big O indicate how many times your program will loop or how many instructions will be executed in a loop? Explain please. I am confused.

  1. Given the following formulas for algorithm efficiency, express each formula in Big O notation:
  1. n3 + 5 n2
  2. 3n2 + 5n* 5n
  3. 250n2 * 100n
  4. the number of times a number n can be divided by 5 before dropping below 5.

What is the Big O for each of the following code?

  1. for ( i = 0; i < n; i ++ )

{ j += i; }

  1. for ( k = 2*n; k > 0; k-- )

{ j = k * 2;

for ( j = 0; j < n*n; j++ )

tot = tot + j * k;

}

  1. i = n;

while ( i > 0 )

{ acc = acc + i * n * n;

i = i / 2;

}

  1. k = n * n;

for ( i = 0; i < n; i++)

while ( k > 0 )

{ acc = acc + i * k;

k = k / 2;

}

  1. for ( i = 0; i < n*n; i ++ )

{ k = 0;

while ( k < n*n )

{ acc = acc + k * i;

k = k * 2;

}

}

  1. k = n * n;

for ( i = 0; i < n; i++)

{ t = t + i * i;

s = t / 2;

}

while ( k > 0 )

{ acc = acc + i * 5;

k = k / 2;

}

  1. int *p;

p = head; ; beginning of link list

while ( p != null && ( p->value != target ) p = p -> linky;

  1. Why is the Big O of the Bubble sort and the Selection Sort consider to be n2?

  1. What is the Big O value of 'Insert' operation into a Stack?

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

Step: 3

blur-text-image

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

Describe how to train managers to coach employees. page 404

Answered: 1 week ago

Question

Discuss the steps in the development planning process. page 381

Answered: 1 week ago