retagged by
1,199 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

700
views
1 answers
1 votes
Souvik33 asked Dec 17, 2022
700 views
What is the worst case time complexity of an efficient algorithm (in order of n) to get the last index for an actually filled element, in an array, given the condition th...
559
views
0 answers
0 votes
kauray asked Jan 6, 2019
559 views
A two dimensional array is stored in column major form in memory if the elements are stored in the following sequence $$A[0][0] A [0] A [0]...A[n_1-1][0] ... A[0] A .....
2.8k
views
1 answers
1 votes
sripo asked Nov 15, 2018
2,812 views
This question is in CLRS,if we have a max heap it is always in sorted order(descending) order.And by extension if we have min heap the array is sorted in ascending order....
3.0k
views
1 answers
1 votes
Na462 asked Aug 22, 2018
3,014 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...