Consider the following function: 1 def func(1st: List[int]) -> None: n = len(1st) i = 0...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following function: 1 def func(1st: List[int]) -> None: n = len(1st) i = 0 j = 1 while i < n: if 1st (i] >= 0: i = i + j 2 3 4 7. else: = abs (1st (i] ) 1st [i] i = 0 j-j+ 2 10 11 (a) Find, with proof, an inmput family for func whose running time is O(log n). (b) Find, with proof, an input family for func whose running time is O(n) and for which the else branch (Lines 9-11) executes 2(log n) times. To simplify your analysis, you may assume n (the length of the list) is a power of 2.4 You may use the following formula, valid for all n eN and r eR where r + 1: n-1 1- r" Σ i-0 (c) Prove that the worst-case running time for func is O(n). Consider the following function: 1 def func(1st: List[int]) -> None: n = len(1st) i = 0 j = 1 while i < n: if 1st (i] >= 0: i = i + j 2 3 4 7. else: = abs (1st (i] ) 1st [i] i = 0 j-j+ 2 10 11 (a) Find, with proof, an inmput family for func whose running time is O(log n). (b) Find, with proof, an input family for func whose running time is O(n) and for which the else branch (Lines 9-11) executes 2(log n) times. To simplify your analysis, you may assume n (the length of the list) is a power of 2.4 You may use the following formula, valid for all n eN and r eR where r + 1: n-1 1- r" Σ i-0 (c) Prove that the worst-case running time for func is O(n).
Expert Answer:
Answer rating: 100% (QA)
Solution a for a running time of thetalognwe need to have negative values at every power of 2 index ... View the full answer
Related Book For
Calculus Early Transcendentals
ISBN: 978-0321947345
2nd edition
Authors: William L. Briggs, Lyle Cochran, Bernard Gillett
Posted Date:
Students also viewed these programming questions
-
Consider the following function and its power series: a. Let S n (x) be the sum of the first n terms of the series. With n = 5 and n = 10, graph f(x) and S n (x) at the sample points x = -0.9, -0.8,...
-
Consider the following function f: X R f(x, x) = -9x-10x2+0 [-In(100x-x) - In(x) - ln(x) - In(50 - x + x)] where is a given parameter and X = {(x1, x) x > 0, x > 0, x + x < 100, x1 - x2 < 50}....
-
Consider the following function G[j, k, d, d2] = true if it is possible to allocate k of the first j precincts to district 1 and at the same time achieve at least d, votes for party A in district 1...
-
Pieman Products Ltd makes road trailers to the precise specifications of individual customers. The following are predicted to occur during the forthcoming year, which is about to start: All direct...
-
Let A and consider TA : R2 R2. (a) Show that the only eigenvalue of TA is A = 0. (b) Show that ker(TA) = (R) is the unique TA-invariant subspace of R2: (except for 0 and R2). 0 0
-
What is the electric field amplitude associated with the light from a red laser pointer? Assume a power of 0.10 mW with a wavelength of 600 nm.
-
Assuming the same data as given in problem 9, was the well in each case profitable? Discuss your answer. Problem 9:- Property cost (acquisition cost). Drilling cost (one well). Estimated completion...
-
Beverage Products Company specializes in 12-ounce drinking glasses. The president asks the controller to prepare a performance report for April. The following report was handed to her a few days...
-
Engineers at electronic company use special wire to manufacture fuzzy logic circuit boards. The wire comes in 1,260 foot rolls that cost $2,700 each. Each board requires 4 1/5 feet of wire. How many...
-
An experiment was conducted regarding a quantitative analysis of factors found in high-density lipoprotein (HDL) in a sample of human blood serum. Three variables thought to be predictive of, or...
-
An assurance practitioner has been asked to carry out a review of a sales forecast that has been prepared by management that will be issued to shareholders. The forecast predicts that sales will...
-
New immigrants generally face an "entry effect" in terms of the wages they can expect to earn relative to a comparable local-born worker. Describe three factors that may contribute to this entry...
-
briefly discuss the HR tools used in performance management process and explain why would you apply them in your organisation. Provide Harvard style references
-
1.- What are the main elements that the case considers to promote good teacher-student interaction? 2.- How can the teacher promote a good communication process that contributes to interaction? 3.-...
-
A company analyzes its data and assesses that because of price increases in some products, customers shifted their product purchases to products that differed from what was originally forecasted....
-
how does communication make a good design challenge team ?
-
How do I make this example parallel. 3. Here are some helpful hints on how to make a list parallel: 1) Figure out what parts of the sentence are being compared. 2) You need to then decide whether...
-
Research an article from an online source, such as The Economist, Wall Street Journal, Journal of Economic Perspectives, American Journal of Agricultural Economics, or another academic journal. The...
-
Use a calculator and right Riemann sums to approximate the area of the given region. Present your calculations in a table showing the approximations for n = 10, 30, 60, and 80 subintervals. Comment...
-
Find the critical points of the following functions on the given intervals. Identify the absolute maximum and minimum values (if they exist). Graph the function to confirm your conclusions. f(x) = 2x...
-
A projectile is launched vertically from the ground at t = 0, and its velocity in flight (in m/s) is given by v(t) = 20 - 10t. Find the position, displacement, and distance traveled after t seconds,...
-
The group \(\mathrm{D}_{3}\) in Schoenflies notation (32 in international notation, which is read "three-two"; see Table 5.1 ) consists of the proper (those not reflections or inversions) covering...
-
Derive the two-dimensional matrix representation Tic)=(2) Tin)=(3) Tex)=(37) (69) T(c2b)= 1 TO)-(71) 10-(11) TO=(9) = for the group D3, using the basis (e1, e2) defined in the following figure.
-
Prove that the matrix representation of \(\mathrm{D}_{3}\) worked out in Problem 5.6 is irreducible. Data from Problem 5.6 Derive the two-dimensional matrix representation Tic)=(2) Tin)=(3)...
Study smarter with the SolutionInn App