in DS
440 views
1 vote
1 vote
Given a set of n elements not all distinct, the majority element is the one with frequency  >=n/2. So majority element is always the

a. Maximum element

b. Minimum element

c. Mean element

d. Median element
in DS
440 views

1 Answer

1 vote
1 vote
Option D median element is the correct answer.

In question the definition  of majority is given as the number which have frequency more than and equal to n/2. As we know to find the median Of n elements we have to put them in their value order (sorted) and then have to select the middle element.

so if any array with n elements have a majority value than it must be present as the median of the array.

1 comment

thanks. I got it now
0
0

Related questions

4 votes
4 votes
3 answers
1