Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complexity Classes Order of N, O(?) Useful mathematical summations: 1+2+3+.....+(n - 1)+n = 2 n ( n + 1 ) a 0 + a 1


Complexity Classes Order of N, O(?)


Useful mathematical summations:


1+2+3+.....+(n - 1)+n =2n(n+1)


a0 + a1 + a2 + a3 + ....+ a(n-1) + an =a1an+11


20 + 21 + 22 + 23 + .... + 2(n-1) + 2n =212n+11



If in some way by (a) a diagram, (b) showing the order of each line of code in braces and finding the dominant term, (c) a graphical representation or (d) a few sentences.


Run Time Complexity/Algorithm Efficiency


1. What is the order of n, O(f(n)) for the following nested loop?

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

for (j = 1; j <= i ; j+ + )

k = k + i + j ;



2. What is the order of n, O(f(n)) for the following nested loop?

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

for (j = 1; j <= 20; j+ +)

k = k + i + j;



3. What is the order of n, O(f(n)) of the following function?

n3+50n2+n



4. What is the order, O(f(n)) of the following function?

2n+2n3+5n




5. Suppose an algorithm takes exactly the given number of statements for each value below, in terms of the size of n, i.e., the order of n, O(f(n)). Explain.


nlogn+logn+n




6. Suppose an algorithm takes exactly the given number of statements for each value below, in terms of the size of n, i.e., the order of n, O(f(n)). Explain.


n2logn+2n

Step by Step Solution

3.30 Rating (147 Votes )

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

Corporate Finance

Authors: Stephen Ross, Randolph Westerfield, Jeffrey Jaffe

13th International Edition

1265533199, 978-1265533199

More Books

Students also viewed these Programming questions

Question

Describe effectiveness of reading at night?

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago