Please consider the following code fragments (a), (b), (c) and (d) where n is the variable specifying data size and C is a constant. What is the tight bound big-Oh time complexity in terms of n in each case? Show
all necessary steps.
(a) for (int i = 0; i < n; i = i + 10)
---------for (int j = 1; j < 1024; j = j*2)
---------------Sum[i] += j * Sum[i];
b) for (int i = 1; i < n; i = i*2)
---------for (int j = 0; j < i; j = j+2)
---------------Sum[i] += j * Sum[i];
c)for (int i = 1; i < n; i = i * 2)
--------for (int j = 1; j < i; j = j * 2)
-------------Sum[i] += j * Sum[i];
d)for (int i = 0; i < n; i++)
--------for (int j = 1; j < n; j *= C)
------------- Sum[i] += j * Sum[i];
(I USED THE DASHED LINES BECAUSE IT WASN'T ALLOWING ME TO SUBMIT WITH EXTRA SPACES. SO, CONSIDER THE DASHED LINES AS SPACES/TABS)
Step by stepSolved in 6 steps with 7 images
- 4. Given the following recursive definitionseq(1) = seq(2) = 1seq(n) = 2 ∗ seq(n − 1) + 3 ∗ seq(n − 2)implement the corresponding program and use it to calculate seq(5).How many invocations are made to the function seq when calculating seq(5)?arrow_forwardFor each of the following function, indicate the class Q(n) the function belongs (use the simplest g(n) possible in your answer. a) (n + 1)10 b) 2nlog2(n+2)2 + (n+2)2log2(n/2) c) 2n+1+ 3n-1 d) (n 2 / 2) - 4narrow_forwardDiscrete matharrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education