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
-
I have a question regarding learning methods. I learn exceptionally well by visual methods such as videos or online recorded lectures. Sometimes lectures come with the words incorporating the text to...
-
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
-
What are the business communicator's most important goals in communicating negative news?
-
Verify that (3.35) is always true. (3.35)
-
Will a share with a higher than average required rate of return for the same risk, be undervalued or overvalued?
-
New York City is the most expensive city in the United States for lodging. The mean hotel room rate is $204 per night (USA today, April 30, 2012). Assume that room rates are normally distributed with...
-
Draw a Venn diagram and use the given information to fill in the number of elements in each region. n(A)=15, n(AnBnC)=4, n(An C)=12, n(An B')= 9, n(BnC)-9, n(A' n B' nC)-20, n(Bn c')=5, n(BUC)=35...
-
1 4 5 6 1 2 QUESTIONS 3) Use reference formulas (VLOOKUP, INDEX/MATCH, XLOOKUP) to find the only transaction date where CUST-001 bought PROD-199 from us this year. Note that your lookup value in this...
-
AquaFlow Bottling produces bottled water. In its Blending Department, materials are added at the beginning of the process, and conversion costs are added evenly throughout. In October, the department...
-
A reasonable accommodation of an employee's religion is one that eliminates the confli between employment requirements and religious practices. Ms. Wilson began wearing a button with a photo of an...
-
Discuss the different mechanisms on how ECOWAS raise their funds give introduction, conclusion and references
-
Erin is planning to retire at age 65.She is 25 years of age today.She wants to retire with a nest egg of $3,000,000.00.What does she need to start saving each month to reach her goal if she starts...
-
Newton's Laws Recall Newton's third law of motion -- For every reaction there is an equal and opposite reaction. Your friend says: "If that is true, that means that the force of gravity the Earth...
-
While "[t]he Islamic Republic of Iran does not publicly communicate on their cyber offensive doctrine," [1] in what ways does the observed use of their capabilities showcase Iran "play[s] by...
-
according to Malone, D. M., & Gallagher, P. A. (2010) how can professionals work together collaboratively? According to Whitbread, K. M., Bruder, M. B., Fleming, G., & Park, H. J. (2007) how can...
-
Tiger, Inc. signed a lease for equipment on July 1, 2007.The lease is for 10 years (the useful life of the asset).The first of 10 equal annual payments of $500,000 was made on July 1, 2007.The...
-
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...
-
Which of the following is NOT an implication of Section 302 of the Sarbanes-Oxley Act? a. Auditors must determine, whether changes in internal control has, or is likely to, materially affect internal...
-
Which of the following is NOT a potential threat to computer hardware and peripherals? a. low humidity b. high humidity c. carbon dioxide fire extinguishers d. water sprinkler fire extinguishers
-
Which of the following is NOT a control implication of distributed data processing? a. redundancy b. user satisfaction c. incompatibility d. lack of standards
Study smarter with the SolutionInn App