Question

1. (25 points) Assume each expression listed below represents the execution time of a program Express the order of magnitude
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER::-

AS FOR GIVEN DATA....

Points considered while calculating Big O notation , we drop constants like O(5N) will become O(N), also we drop additions or subtractions , O(N-2) becomes O(N).

a) T(n) = n3 + 100 N.log2n + 5000

We will drop constants

n3 + log2n
O(n3) + O(log(n))

b) T(n) = 2n + n99 + 7

Here 2^n will varry according to n hence the time taken for n^99 will define the time complexity for 2^n as well so we drop it and 7 is constant so we will drop that as well

Hence it will be O(n^99)

c) T(n) = n^2-1/n+1 + 8log2n

Here n^2-1 will be treated as (n^2) and n+1 will be as O(n) hence O(n) will be covered by O(n^2) so it becomes O(n^2) and 8log2n will be O(log(n)

So, O(n^2) + O(log(n))

D) T(n) = 1+2+....+2n-1

the expression completely depends on 2^n-1 so O(n-1)

2. Since the loop doe not depend on value of n instead it depends on value of x , which has to be entered by user.if user never enter x -999 then loop will be executed infinitly in the worse case, big o

O(∞)

best case O(1) when user enter x !=999 , and once in while loop enters -999 , so loop executed for one time

Add a comment
Know the answer?
Add Answer to:
1. (25 points) Assume each expression listed below represents the execution time of a program Express...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Determine the appropriate big-o expression for each of the following functions, and put your answer...

    1. Determine the appropriate big-o expression for each of the following functions, and put your answer in the table we have provided in section 2-1 of ps5_parti. We've included the answer for the first function. (Note: We're using the “ symbol to represent exponentiation.) a (n) = 5n + 1 b. b(n) = 5 - 10n - n^2 o c(n) = 4n + 2log (n) d. e. d(n) = 6nlog (n) + n^2 e(n) = 2n^2 + 3n^3 - 7n...

  • 4. Big-Oh and Rune time Analysis: describe the worst case running time of the following pseudocode...

    4. Big-Oh and Rune time Analysis: describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. howing your work is not required (although showing work may allow some partial t in the case your answer is wrong-don't spend a lot of time showing your work.). You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for...

  • (10') 6. For each of the following code blocks, write the best (tightest) big-o time complexity...

    (10') 6. For each of the following code blocks, write the best (tightest) big-o time complexity i) for (int i = 0; ǐ < n/2; i++) for (int j -0: ni j++) count++ i) for (int í = 0; i < n; i++) for (int ni j0 - for (int k j k ni kt+) count++ İİİ) for (int í ー 0; i < n; i++) for(int j = n; j > 0; j--) for (int k = 0; k...

  • They NAME sc 162- lec. 18 (Big quiz 1. Arrange the following functions in order of...

    They NAME sc 162- lec. 18 (Big quiz 1. Arrange the following functions in order of increasing rate of growth. Also, identify any functions with the SAME rate of growth by putting then below the others. a) sn, 44log n, 10n log n, 500, 2n, 28, 3n b) n', n +2 nlog2 n, n! ne log, n, n n n'. 4", n, na, 2 2. Use the Big-o notation to estimate the time complexity for the following segments/methods. (Assume all...

  • Provide a "big oh" run-time analysis for each of the following. When a value of “n”...

    Provide a "big oh" run-time analysis for each of the following. When a value of “n” is used, it is the size of the input. 4.) void problem 40 cin n min max for (int i min i n, i++) for (int j- 1: j< max, j++) tota while (total n tota total 2 total 5.) void problem 50 cin n; for (int i 0: i n, i++) for (int j 0; j i2; j++) for (int k 0; k...

  • Question 1 (25 pts) Find the running time complexity for the following code fragments. Express yo...

    Question 1 (25 pts) Find the running time complexity for the following code fragments. Express your answers using either the Big-O or Big-Θ notations, and the tightest bound possible. Justify your answers. for(int count O , i -0; i < n* n; i++) for(int i0 ; j <i; j++) count++ for(int count O , i -0; i

  • For each of the following six program fragments: a. Give an analysis of the running time...

    For each of the following six program fragments: a. Give an analysis of the running time (Big-Oh will do). b. Implement the code in the language of your choice, and give the running time for several values of N. Pseudo Code Implementation Analysis of runtime time (Big-Oh) (1) sum = 0; for(i = 0; i < n; ++i) ++sum; (2) sum = 0; for(i = 0; i < n; ++i) for(j = 0; j<n; ++i) ++sum; (3) sum = 0;...

  • Not sure if I did the mergesort execution correct as well as the merge execution. Can...

    Not sure if I did the mergesort execution correct as well as the merge execution. Can you try explaining it visually sort of like how I was approaching it visually. After that translate it to c++ code if possible. I saw another post that used int *L = new int[n1+1] in the merge function which is the same as int L[n1 +1]correct? Heres my driver function int main () € cout << "Enter length you'd like the array Leendl; int...

  • hi show your solution in full details not just the final answer ,cheers mate can you...

    hi show your solution in full details not just the final answer ,cheers mate can you help please thanks I am stuck please Answer the following questions: Given the code segments below with n as the problem size, answer the following questions: //Code Segment 1 (Consider n as a power of 3) int sum = 0; for(int i = 1; i <= n; i = i*3)                sum++;                                    // statement1 //Code Segment 2: (Consider both possibilities for x) if(x...

  • c++ help Write a program that obtains the execution times for the following three code segments...

    c++ help Write a program that obtains the execution times for the following three code segments with the different n. code 1: for(int i = 0; i <= n; i++)   { x = i; } code 2: for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { x = i + j; } } code 3: for (int i = 0; i <= n; i++) { for (int j =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT