Consider an array A[1..n] such that n = k 2f for some positive parameter k and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider an array A[1..n] such that n = k· 2f for some positive parameter k and a positive integer parameter f. We assume that all elements in A have different values. a) Describe an algorithm that runs in time O(n. 2f) and distributes the elements of A among 2f arrays B₁ [1..k]. Any element in the sub-array B; must be smaller than any element in the sub-array B, if i < j. In other words: every element of A is copied to some Bi[j] so that B₁₁[₁] < B₁₂ [2] if and only if i < i2. For example, let A {1,8, 3, 5, 2, 9} and f = 1. Then the array B₁ would contain elements 1, 3, and 2 (in any order) and the array B₂ will contain elements 9, 8, and 5 (in any order). b) Describe an algorithm that achieves the same result as in (a) in time O(n • f). Remark: Observe that f can be very small. For instance, f = log log n. Hence, sorting of the array A would take too much time. Solutions based on sorting the array A (or assuming that the array is sorted) are wrong. - Consider an array A[1..n] such that n = k· 2f for some positive parameter k and a positive integer parameter f. We assume that all elements in A have different values. a) Describe an algorithm that runs in time O(n. 2f) and distributes the elements of A among 2f arrays B₁ [1..k]. Any element in the sub-array B; must be smaller than any element in the sub-array B, if i < j. In other words: every element of A is copied to some Bi[j] so that B₁₁[₁] < B₁₂ [2] if and only if i < i2. For example, let A {1,8, 3, 5, 2, 9} and f = 1. Then the array B₁ would contain elements 1, 3, and 2 (in any order) and the array B₂ will contain elements 9, 8, and 5 (in any order). b) Describe an algorithm that achieves the same result as in (a) in time O(n • f). Remark: Observe that f can be very small. For instance, f = log log n. Hence, sorting of the array A would take too much time. Solutions based on sorting the array A (or assuming that the array is sorted) are wrong. -
Expert Answer:
Answer rating: 100% (QA)
Lets tackle both parts of your question a Algorithm for On 2f To d... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these operating system questions
-
PLEASE GIVE CORRECT ANSWERS Prove that the number of comparators in any sorting network is (n log n). [4 marks] (ii) What does Part (d)(i) imply in terms of the depth of any sorting network? [1 mark]...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
A share of preferred stock pays a dividend of $5 per year. If the price of this preferred stock is currently $100, what is the cost of preferred stock? Fill in the blank
-
Why might it be a bad idea to be blunt and terse toward students and other people on a budget when denying them credit?
-
Describe the zinccarbon, or Leclanch, dry cell and the lead storage battery.
-
Consider a source of flow in \(3 \mathrm{D}\) of strength \(S\) (dimensions \(L^{3} / T\) ), Then the flow is axisymmetric and independent of the \(\theta\)-direction in the spherical coordinate...
-
Do you think global businesses would be willing to subscribe to a global code of conduct? Explain your answer.
-
3: On the grid below graph the exponential function y = 2* and its inverse. a. What is the equation of the inverse of y = 2*? How would we solve it for y? b. In what quadrants does the graph of the...
-
Bear Park, a camping ground in the Lake District, has compiled the following financial information as of December 31, 2020. Instructions a. Determine Bear Parks net income for 2020. b. Prepare a...
-
Q2 Demonstrate the difference between Syntax error and Semantic Error while practicing MATLAB - using screen shots, which one is more dangerous, support your answer by valid logical argument? (CLO...
-
A rectangular plate of density \(\sigma=1.2510^{2} \mathrm{~kg} \mathrm{~m}^{-2}\) is arranged with the longer side \(\ell=75\) \(\mathrm{cm}\) along the \(x\) axis of a Cartesian reference frame,...
-
A cylinder of mass \(M=2.0 \mathrm{~kg}\) and radius \(R=10 \mathrm{~cm}\) is resting on a horizontal plane, and its center \(\mathrm{O}\) is connected to a point \(\mathrm{P}\) on the plane by a...
-
A disk of mass \(M=470 \mathrm{~g}\) and radius \(R=15 \mathrm{~cm}\) rolls without crawling on a horizontal plane. A point mass \(m=240 \mathrm{~g}\) impacts on it and remains attached, Fig. 12.13....
-
As shown in Fig.12.14, an object that can be considered point-like with mass \(m=0.50 \mathrm{~kg}\) is resting on a rough horizontal surface with dynamic friction coefficient \(\mu=0.30\). At the...
-
A homogeneous sheet of mass \(M=8.0 \mathrm{~kg}\), side \(D=50 \mathrm{~cm}\) and negligible thickness can rotate without friction about the horizontal axis passing through point \(A\) and...
-
A condensed income statement by product line for Celestial Beverage Inc. indicated the following for Star Cola for the past year: sales 290,000 Cost of goods sold 155,000 Gross profit 135,000...
-
Suppose you won a financial literacy competition and are given FJS10000 to invest, with the condition that investment can be done either in, i) Invest in Unit trust of Fiji or Invest in Fijian...
-
Solve the following linear program using SIMPLEX: maximize 18x1 + 12.5x2 subject to X1 + X2 < 20 X1 < 12 X2 < 16 X1, X2 0 .
-
GREEDY-SET-COVER can return a number of different solutions, depending on how we break ties in line 4. Give a procedure BAD-SET-COVER-INSTANCE (n) that returns an n-element instance of the...
-
The proof of Lemma 34.6 assumes that the working storage for algorithm A occupies a contiguous region of polynomial size. Where in the proof do we exploit this assumption? Argue that this assumption...
-
The following extracts have been taken from the subsidiary books of the business owned by D. Jenkinson for the month of April 2017. Required: (a) The name of the source document which will have been...
-
In which book should all the correcting double entries first be entered?
-
After preparing its draft final accounts for the year ended 31 March 2013 and its draft statement of financial position as at 31 March 2013 a business discovered that the inventory lists used to...
Study smarter with the SolutionInn App