An element is the majority of a size-n array A [1...n] if it occurs more than...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
An element is the majority of a size-n array A [1...n] if it occurs more than 1 times in the array. Design a O(log n) time algorithm to find the majority of A in the EREW PRAM model using n processors where c is some constant. The smaller the constant c is, the better. Hint: adapt the algorithm in section 4 in this note Algorithm 5: Find majority 1 Function Majority (A[1...n]) /* take care of the case A has an odd number of elements if A is odd then Count A[1] in A. This takes O(n) time. if count >n/2 then else return A[1] | A=A[2...n] end if 2 3 4 5 6 7 8 9 for i=1,2,4,...,n/2 do 10 11 12 13 | if A[21] =A[21] then Add a copy of A[i] to B end for x = Majority(B) Count in A. If x is the majority of A, return r. Otherwise, return "no majority". The running time is given by the following recurrence T(n) = T(n/2) + O(n) which is O(n) by master theorem. An element is the majority of a size-n array A [1...n] if it occurs more than 1 times in the array. Design a O(log n) time algorithm to find the majority of A in the EREW PRAM model using n processors where c is some constant. The smaller the constant c is, the better. Hint: adapt the algorithm in section 4 in this note Algorithm 5: Find majority 1 Function Majority (A[1...n]) /* take care of the case A has an odd number of elements if A is odd then Count A[1] in A. This takes O(n) time. if count >n/2 then else return A[1] | A=A[2...n] end if 2 3 4 5 6 7 8 9 for i=1,2,4,...,n/2 do 10 11 12 13 | if A[21] =A[21] then Add a copy of A[i] to B end for x = Majority(B) Count in A. If x is the majority of A, return r. Otherwise, return "no majority". The running time is given by the following recurrence T(n) = T(n/2) + O(n) which is O(n) by master theorem.
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
(I need answer for part 4 and 5 only) The Simpsons, owners of a spa on the island of Montreal, have been hard-hit by the pandemic.Before they were forced to close their spa, their take home income,...
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
A company has the following results for the three years to 31 October 2020: Assuming that all possible claims are made to relieve the trading loss against total profits, calculate the company's...
-
Describe the differences in setting premiums using schedule and class rating systems.
-
Te amino acid arginine ionizes according to the following scheme: (a) Calculate the isoelectric point of arginine. You can neglect contributions from form I. Why? (b) Calculate the average charge on...
-
What is the rate of return required by the shareholder equal to?
-
Time cards are being entered into the accounting system for four employees. The costs for Employee 1 are to be billed to job cost code 302.01.01100L. Ten hours of Employee 2 time is to be billed to...
-
Sargunaraj Manufacturing purchases $72,900 of raw materials on account, and it incurs $80,800 of factory labour costs. Supporting records show that (a) the assembly department used $62,700 of raw...
-
The Town of Weston has a Water Utility Fund with the following trial balance as of July 1, 2019, the first day of the fiscal year: Credits Cashi Customer accounts receivable Allowance for...
-
Quantitative Problem: Bellinger Industries is considering two projects for inclusion in its capital budget, and you have been asked to do the analysis. Both projects' after-tax cash flows are shown...
-
Explain the different quality management methods that are applicable to a project organization.
-
What is a System Operations Dictionary?
-
What makes a system, product, or service unique?
-
Discuss the various standards for monitoring project quality.
-
What is a system characteristic?
-
The information in this paragraph applies to this question and the two questions that follow. The dollar value of monthly sales for Illini volleyball t - shirts with Vrankovic's name and player...
-
How can you tell from the vertex form y = a(x - h) 2 + k whether a quadratic function has no real zeros?
-
The Luxon Company produces industrial and residential lighting fixtures at its manufacturing facility in Calgary. Shipment of company products to an eastern warehouse is presently handled by common...
-
Tsumagari Company, an electronics company in Kobe, Japan, is planning to buy new equipment to produce a new product. Estimated data (monetary amounts are in thousands of Japanese yen) are: Assume a...
-
Assume that income tax rates are 30 percent and that the asset qualifies for a 25 percent declining balance, and the required rate of return is 10 percent. 1. The book value of an old machine is...
Study smarter with the SolutionInn App