Question

in my c++ class i need help with these question please Question 1. Indicate whether the...

in my c++ class i need help with these question please

Question 1. Indicate whether the first function of each of the following pairs has a smaller, same, or larger order of growth (to within a constant multiple) than the second function. Use the correct notation to indicate the order of growth (f(n) ∈O(g(n)), Ω(g(n)), or Θ(g(n)) as applicable). Prove your statement using limits. (a) (lnn)2 and lnn2 (b) 42n+1 and 42n

Question 2. Use the formal definitions of O, Ω, and Θ to prove the following: (a) lnn ∈ Θ(log2 n) (b) 100n3 ∈ Ω(n2)

Question 3. Order the following functions according to their order of growth from lowest to highest. Ties, if any, must be clearly stated. (a) log2 n10 (b) 6 √n (c) log2 n (d) (n + 1000)! (e) 3n (f) 1.93n (g) n8 1000 (h) n−6000 (i) 0.0001n2 + 105n (j) nlogn Question 4. For each of the following program fragments, give an analysis of the running time (Big-Oh will do). Give the exact value leading to the Big-Oh conclusion, and show your work. sum = 0; //1 for( i = 0; i < n; ++i ) ++sum; sum = 0; //2 for( i = 0; i < n; ++i ) for( j = 0; j < n; ++j ) ++sum; sum = 0; //3 for( i = 0; i < n; ++i ) for( j = 0; j < n * n; ++j ) ++sum;

Question 5. Define a Rectangle class that provides getLength and getWidth. Write a main that creates a vector of Rectangles and finds the largest Rectangle on the basis of area. For this part of the assignment, you need to submit a separate .cpp source code file as well as screenshots in your homework submission indicating successful testing of the code. No credit will be given for code that does not compile or segfaults.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

1 is solved as per the HOMEWORKLIB RULES, please repost others.

1)

a)

(log2n)2 and log2 n2

===> log22 n = log2 n * log2 n and

and

log2 n2 = 2 log n.

(According to the logarithmic property)

which means

b)

4^(2n+1) and 4^2n

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

Add a comment
Know the answer?
Add Answer to:
in my c++ class i need help with these question please Question 1. Indicate whether the...
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
  • Please DONOT attempt this Big O question if you don't know the exact answer. Algorithms question...

    Please DONOT attempt this Big O question if you don't know the exact answer. Algorithms question (Big O): Please explain me in details the order of growth (as a function of N) of the running times of each of the following code fragments: a)         int sum = 0; for (int n = N; n > 0; n /= 2)    for(int i = 0; i < n; i++)      sum++; b)         int sum = 0; for (int i =...

  • Need help with 1,2,3 thank you. 1. Order of growth (20 points) Order the following functions...

    Need help with 1,2,3 thank you. 1. Order of growth (20 points) Order the following functions according to their order of growth from the lowest to the highest. If you think that two functions are of the same order (Le f(n) E Θ(g(n))), put then in the same group. log(n!), n., log log n, logn, n log(n), n2 V, (1)!, 2", n!, 3", 21 2. Asymptotic Notation (20 points) For each pair of functions in the table below, deternme whether...

  • I need help fixing my code: In C++ *************** 1) I want to sum the digits...

    I need help fixing my code: In C++ *************** 1) I want to sum the digits of an n*n matrix 2) find the average I have completed the rest ****Do not use C++ standard library. You must use pointers and pointer arithmetic to represent the matrix and to navigate through it. MY CODE: (I have indicated at which point I need help) #include <iostream> using namespace std; void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp;...

  • 1. (25 points) Assume each expression listed below represents the execution time of a program Express...

    1. (25 points) Assume each expression listed below represents the execution time of a program Express the order of magnitude for cach time using big O notation. a. T(n) = ns + 100n . log2 n + 5000 b. T(n) = 2" +n” + 7 d. T(n) 1+2+4+2 2 (75 points+5 extra credit) For cach of the code segments below, determine an equation for the worst-case computing time Tn) (expressed as a function of n, ie. 2n+4) and the order...

  • I need help with question 2, 3 and 4 please. Thanks in advance. Answer the following...

    I need help with question 2, 3 and 4 please. Thanks in advance. Answer the following questions: 1. Prove that any polynomial of degree k is O (nk 2. By finding appropriate values ofc and no, prove that: f(n) 4 n log2 n + 4 n2 + 4 n iso(n2). 3. Find functions fi and fi such that both fi(n) and /i(n) are O(g(n)), but fi(n) is not OG(n)) 4. Determine whether the following statements are true or false. Briefly...

  • Question 3: Given the following two code fragments [2 Marks] (i)Find T(n), the time complexity (as...

    Question 3: Given the following two code fragments [2 Marks] (i)Find T(n), the time complexity (as operations count) in the worst case? (ii)Express the growth rate of the function in asymptotic notation in the closest bound possible. (iii)Prove that T(n) is Big O (g(n)) by the definition of Big O (iv)Prove that T(n) is (g(n)) by using limits

  • 8.         R-4.8 Order the following functions by asymptotic growth rate. 4nlogn + 2n 2^10    2^logn 3n...

    8.         R-4.8 Order the following functions by asymptotic growth rate. 4nlogn + 2n 2^10    2^logn 3n + 100logn      4n     2^n n^2 + 10n        n^3       nlogn 9.         R-4.9 Give a big-Oh characterization, in terms of n, of the running time of the example 1 method shown in Code Fragment 4.12. 10.       R-4.10 Give a big-Oh characterization, in terms of n, of the running time of the example 2 method shown in Code Fragment 4.12. 11.       R-4.11 Give a big-Oh characterization, in...

  • 1. (10 pts) For each of the following pairs of functions, indicate whether f = 0(g),...

    1. (10 pts) For each of the following pairs of functions, indicate whether f = 0(g), f = Ω(g), or both (in which case f-6(1). You do not need to explain your answer. f(n) (n) a) n (b) n-1n+1 (c) 1000n 0.01n2 (d) 10n2 n (lg n)2 21 е) n (f) 3" (g) 4" rl. 72 i-0 2. (12 pts) Sort the following functions by increasing order of growth. For every pair of consecutive functions f(n) and g(n) in the...

  • Please I need help in C language, I am trying to modify the code per the...

    Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions:                  1.      First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....

  • 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

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