edited by
1,385 views

1 Answer

1 votes
1 votes
if any element is present more than n/2 times in the array then that element is called majority element.The best way to implement this is through a BST.Node of the Binary Search Tree: struct tree { int element; int count; }BST; Insert elements in BST one by one and if an element is already present then increment the count of the node. At any stage, if count of a node becomes more than n/2 then return. ref:http://www.geeksforgeeks.org/majority-element/

Related questions

0 votes
0 votes
2 answers
1
dhruba asked Jun 5, 2023
1,151 views
Binary search is performed on a sorted array of n elements. The search key is not in the array and falls between the elements at positions m and m+1 (where 1 ≤ m < n). ...
8 votes
8 votes
2 answers
2
1 votes
1 votes
1 answer
3
Tuhin Dutta asked Dec 13, 2017
1,270 views
In a sorted array, every element is repeated more than once except one. what will be the time complexity to find that element in the worst case?
0 votes
0 votes
1 answer
4
soorajchn asked Mar 14, 2015
5,500 views
a) n- ( lg(n)) - 2b) n + (lg(n)-2)