retagged by
1,173 views
0 votes
0 votes
A Sorted array of n elements contains 0 and 1 to find out majority of 0 and 1.How much time it will take???

and please explain  Meaning -majority of 0 and 1??
retagged by

1 Answer

5 votes
5 votes
I think the answer should be O(1) as the middle element can be found in constant time as the n/2th element is the middle element in. Once found, it can be compared. If it is found to be 1 then the majority is 1 otherwise 0 as it is given as sorted array.

Related questions

0 votes
0 votes
0 answers
2
1 votes
1 votes
1 answer
4
Na462 asked Aug 22, 2018
2,927 views
Consider array A[1..100,1..100],in which elements are stored in Z representation. An example of 5x5 such array is shown below: Base address of array = 1000,size of each e...