Question 3: (10 marks) Find the complexity of the following blocks of code or algorithm's description....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 3: (10 marks) Find the complexity of the following blocks of code or algorithm's description. [Note: your answer must show the steps that lead to your final answer] (2 marks each) 1) count = 1 for i = 1 2) count = 0 for i = 1 to n do for k = 1 to n do for (j = 2;j<n; j*= 2) to 100 do count += i end for for k = 1 to 100 do count = i+ k + j; count *= k end for end for while j< n do count +=j j*= 2; end while end for end for 3) 4) The algorithm solves the problem of size n by dividing it into 8 subproblems of size n/2, recursively solving each sub- problem, and then combining the solutions in The algorithm solves the problem by breaking it into 4 sub-problems of 1/2 the scale, recursively solving each sub-maze, and then combining the solutions in linear time O(n³) time The algorithm solves the problem of size n by recursively solving two sub-problems of size n- 1, and then combining the solutions in constant time. 5) Question 3: (10 marks) Find the complexity of the following blocks of code or algorithm's description. [Note: your answer must show the steps that lead to your final answer] (2 marks each) 1) count = 1 for i = 1 2) count = 0 for i = 1 to n do for k = 1 to n do for (j = 2;j<n; j*= 2) to 100 do count += i end for for k = 1 to 100 do count = i+ k + j; count *= k end for end for while j< n do count +=j j*= 2; end while end for end for 3) 4) The algorithm solves the problem of size n by dividing it into 8 subproblems of size n/2, recursively solving each sub- problem, and then combining the solutions in The algorithm solves the problem by breaking it into 4 sub-problems of 1/2 the scale, recursively solving each sub-maze, and then combining the solutions in linear time O(n³) time The algorithm solves the problem of size n by recursively solving two sub-problems of size n- 1, and then combining the solutions in constant time. 5)
Expert Answer:
Related Book For
Discrete Mathematics and Its Applications
ISBN: 978-0073383095
7th edition
Authors: Kenneth H. Rosen
Posted Date:
Students also viewed these computer engineering questions
-
Find the complexity of a brute-force algorithm for scheduling the talks by examining all possible subsets of the talks.
-
Find the complexity of followings using summation method. Show all steps and do all parts. for(i=1,
-
Complexity show that Prims algorithm has complexity O(n2).
-
Find the frequency domain current I0 as shown. j1 Io 2
-
Other candy-making firms have an average forward P/E ratio of 12 at this time. With a share price of $18.20, what are the expected 2013 EPS for Corines Candies if its forward P/E ratio is the same as...
-
A tennis ball with a mass of 57 g and a diameter of 6.4 cm is hit with an initial velocity of 105 km/h and a backspin of 4200 rpm. Determine if the ball falls or rises under the combined effect of...
-
A mixing basin in a sewage filtration plant is stirred by mechanical agitation (paddlewheel) with a power input \(\dot{W}(\mathrm{ft} \cdot \mathrm{lb} / \mathrm{s})\). The degree of mixing of fluid...
-
For the current period, Kayenta Companys manufacturing operations yield a $ 4,000 unfavorable price variance on its direct materials usage. The actual price per pound of material is $ 78; the...
-
Although anxiety is self-limiting, the nurse can help to reduce anxiety by: (Select all that apply.) 1. providing a safety net for the patient. 2. teaching relaxation exercises. 3. helping the...
-
In this exercise you will be assuming the role of an Account Manager working within our Personal Care Appliances category during Amazon Black Friday. You act as a general manager responsible for...
-
(a) Prove, or give a counterexample to disprove: (i) For all x R: (ii) For all x EZ: |[x] = [x] 42x7- - X (iii) For all x, y, z Z, with z > 1 and zy: (x div y) = ((x % z) div (y % z)) (mod z)...
-
Develop \(\left(\epsilon+B_{t}^{2} ight)^{1 / 2}\) using It's formula. Letting \(\epsilon\) go to 0, prove that \(\left|B_{t} ight|=W_{t}+L_{t}^{0}\), where \(L^{0}\) is the local time at 0 of \(B\)....
-
A \(1.2-\mathrm{kg}\) ball dropped from a height of \(3.0 \mathrm{~m}\) onto a steel plate rigidly attached to the ground bounces back up to a height of \(2.5 \mathrm{~m}\). (a) What is the impulse...
-
Prove that, if \(\tau\) is an initial time with \(\mathbb{E}_{\mathbb{Q}}\left(1 / \alpha_{\infty}^{\tau} ight)
-
A uniform chain of inertia \(m\) and length \(\ell\) is lying on a slippery table. When just the tip hangs over the edge, the chain begins to slip off. (Ignore friction.) Calculate the speed of the...
-
Just before hitting the ground, a partially inflated \(0.625-\mathrm{kg}\) basketball has a speed of \(3.30 \mathrm{~m} / \mathrm{s}\). Then it loses half of its kinetic energy as it bounces. (a)...
-
in100 to 150 words based on your calculations in (a) contrast andcompare each company's overall liquidity position in relation toeach other, and to the industry overall assume the followingindustr...
-
Per Bag Direct materials: 25 pounds of CWhiz-2000 @ $0.08/lb. = $ 2.00 Direct labor: 0.05 hour @ $32.00/hr. = $ 1.60 The company manufactured 100,000 bags of Cheese-Be-Good in December and used...
-
Find the cells in a K-map for Boolean functions with five variables that correspond to each of these products. a) x1x2x3x4 b) x1x3x5 c) x2x4 d) x3x4 e) x3 f) x5
-
Describe inwords the strings in each of these regular sets. a) 1*0 b) 1*00* c) 111 001 d) (1 00)* e) (00*1)* f) (0 1) (0 1)*00
-
Construct a deterministic finite-state automaton that recognizes the set of all bit strings that contain exactly three 0s.
-
When a honeybee flies through the air, it develops a charge of +17 pC. How many electrons did it lose in the process of acquiring this charge?
-
Falling raindrops frequently develop electric charges. Does this create noticeable forces between the droplets? Suppose two 1.8 mg drops each have a charge of +25 pC; these are typical values. The...
-
A housefly walking across a surface may develop a significant electric charge through a process similar to frictional charging. Suppose a fly picks up a charge of +52 pC. How many electrons does it...
Study smarter with the SolutionInn App