We are given a set S of n elements so that the i-th element has value...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
We are given a set S of n elements so that the i-th element has value x; and weight wi. All weights are positive real numbers and the sum of all weights is 1, Σ²±1 Wi = 1. Let a Wi denote the total weight of all elements in S with values less than a. Let >a 2° a Wi denote the total weight of all elements in S with values greater than a. The weighted median of S is the element x satisfying Σ<* Wi < and > <½. For example, suppose that element values are 1, 2, 3, 5, 8, 10, 12 and element weights are 0.05, 0.05, 0.1, 0.1, 0.15, 0.2, 0.35 respectively. Then the weighted median is 10, but the median is the element with value 5. Your input consists of two unsorted arrays X [1..n] and W[1..n], where for each index i, the i-th element has value X [i] and weight W[i]. You may assume that all values are distinct. a) Explain how we can compute the weighted median in O(nlogn) time using sorting. b) Describe an algorithm that computes the weighted median in O(n) time using the linear-time selection algorithm as a subroutine. We are given a set S of n elements so that the i-th element has value x; and weight wi. All weights are positive real numbers and the sum of all weights is 1, Σ²±1 Wi = 1. Let a Wi denote the total weight of all elements in S with values less than a. Let >a 2° a Wi denote the total weight of all elements in S with values greater than a. The weighted median of S is the element x satisfying Σ<* Wi < and > <½. For example, suppose that element values are 1, 2, 3, 5, 8, 10, 12 and element weights are 0.05, 0.05, 0.1, 0.1, 0.15, 0.2, 0.35 respectively. Then the weighted median is 10, but the median is the element with value 5. Your input consists of two unsorted arrays X [1..n] and W[1..n], where for each index i, the i-th element has value X [i] and weight W[i]. You may assume that all values are distinct. a) Explain how we can compute the weighted median in O(nlogn) time using sorting. b) Describe an algorithm that computes the weighted median in O(n) time using the linear-time selection algorithm as a subroutine.
Expert Answer:
Answer rating: 100% (QA)
a To compute the weighted median in Onlogn time using sorting we can follow these steps 1 Combine th... 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
-
The new line character is utilized solely as the last person in each message. On association with the server, a client can possibly (I) question the situation with a client by sending the client's...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
From the data below, how much is subject to regular income tax? * Description Interest income on savings deposits in local banks Income from sale of lot held for investment, located IN Compensation...
-
How would you counter the claim that the indirect organization strategy is unethical or manipulative because the writer deliberately delays the main idea?
-
An electrochemical cell is made by placing a zinc electrode in 1.00 L of 0.200 M ZnSO4 solution and a copper electrode in 1.00 L of 0.0100 M CuCl2 solution. a. What is the initial voltage of this...
-
Verify the vector identity \[\begin{equation*}abla^{2} \boldsymbol{v}=abla(abla \cdot \boldsymbol{v})-abla \times(abla \times \boldsymbol{v}) \tag{15.83}\end{equation*}\]
-
Sean McNamee was the owner of an accounting firm, W. F. McNamee & Co., LLC (WFM), which he founded and formed in Connecticut as a limited liability company (LLC). For federal tax purposes, an LLC can...
-
What are the key considerations in designing a network organizational structure that optimizes knowledge sharing and innovation across decentralized nodes while maintaining strategic alignment and...
-
Baer Belly Bikinis, Inc. (BBB) is a small business located in Santa Monica, California. It sells swimwear and related products to specialty stores throughout the United States. It also sells its...
-
Identify and explain how the use of organizational behavior can lead to the success and failure of an organization.
-
Determine the gravitational potential \(\mathcal{V}_{G}\) in the case of a homogeneous solid sphere of radius \(R\) as a function of \(r>R\).
-
Show that in the case described by the question 4 the point mass \(m\) inside the sphere feels no gravitational force from the spherical shell. Question 4 Show that if you have a mass \(M\)...
-
Making use of the result obtained in the question 3 , determine the gravitational potential \(\mathcal{V}_{G}\) in the case of a homogeneous solid sphere of radius \(R\) as a function of \(r \leq...
-
Verify that if \(a=p_{a}+i q_{a}\) and \(b=p_{b}+i q_{b}\) are two complex numbers, then the product of the two is the complex number. Get real and imaginary part.
-
Show that the elastic force exhibited by a bouncing ball of radius \(R\), assumed perfectly elastic, can be written as \(\mathbf{F}=-k(r-R) b \hat{f} r\) and that it admits potential energy...
-
If the heat of combustion of the wood is 9.8 MJ kg-1 and the power station will generate electricity with an efficiency of 31% when burning wood, calculate how much electricity can be produced (in...
-
Discrete sample spaces: suppose there are N cable cars in San Francisco, numbered sequentially from 1 to N. You see a cable car at random; it is numbered 203. You wish to estimate N. (See Goodman,...
-
Make a 3-by-3 chart with row and column labels WHITE, GRAY, and BLACK. In each cell (I, j), indicate whether, at any point during a depth-first search of a directed graph, there can be an edge from a...
-
Let H be a class of hash functions in which each hash function h H maps the universe U of keys to {0, 1, . . . , m 1}. We say that H is k-universal if, for every fixed sequence of k distinct keys x...
-
The set-partition problem takes as input a set S of numbers. The question is whether the numbers can be partitioned into two sets A and A = S A such that x A x = P x A x. Show that the...
-
Cinnamon, Inc. recorded a total deferred tax asset in Year 3 of \($12\),301, off set by a \($12\),301 valuation allowance. Cinnamon most likely: A . fully utilized the deferred tax asset in Year 3. B...
-
Compared to the provision for income taxes in Year 3, the companys cash tax payments were: A . lower. B . higher. C . the same.
-
Midland Brands issues three-year bonds dated January 1, 2015 with a face value of $5,000,000. Th e market interest rate on bonds of comparable risk and term is 3%. If the bonds pay 2.5% annually on...
Study smarter with the SolutionInn App